Heterogeneous ice nucleation at solid surfaces is important in many physical systems including the Earth's atmosphere. AgI is one of the best ice nucleating agents known; however, why AgI is such an effective ice nucleus is unclear. Using molecular dynamics simulations, we show that a good lattice match between ice and a AgI surface is insufficient to predict the ice nucleation ability of the surface. Seven faces modeled to represent surfaces of both β-AgI and γ-AgI, each having a good lattice match with hexagonal and/or cubic ice, are considered, but ice nucleation is observed for only three. Our model simulations clearly show that the detailed atomistic structure of the surface is of crucial importance for ice nucleation. For example, when AgI is cleaved along certain crystal planes two faces result, one with silver ions and the other with iodide ions exposed as the outermost layer. Both faces have identical lattice matches with ice, but in our simulations ice nucleation occurred only at silver exposed surfaces. Moreover, although hexagonal ice is often the only polymorph of ice considered in discussions of heterogeneous ice nucleation, cubic ice was frequently observed in our simulations. We demonstrate that one possible mechanism of ice nucleation by AgI consists of particular AgI surfaces imposing a structure in the adjacent water layer that closely resembles a layer that exists in bulk ice (hexagonal or cubic). Ice nucleates at these surfaces and grows almost layer-by-layer into the bulk.