Aluminum nitride (AlN) has a polar crystal structure that is susceptible to electric dipolar interactions. The inversion domains in AlN, similar to those in GaN and other wurtzite-structure materials, decrease the energy associated with the electric dipolar interactions at the expense of inversion-domain boundaries, whose interface energy has not been quantified. We study the atomic structures of six different inversion-domain boundaries in AlN, and compare their interface energies from density functional theory calculations. The low-energy interfaces have atomic structures with similar bonding geometry as those in the bulk phase, while the high-energy interfaces contain N-N wrong bonds. We calculate the formation energy of an inversion domain using the interface energy and dipoles' electric-field energy, and find that the distribution of the inversion domains is an important parameter for the microstructures of AlN films. Using this thermodynamic model, it is possible to control the polarity and microstructure of AlN films by tuning the distribution of an inversion-domain nucleus and by selecting the low-energy synthesis methods.