when magnesium (if you are doing an experiment the magnesium and iodine must be in powder or almost powdered) reacts with iodine only if you are adding few drops of water. Immediately can be observed a pink to purple smog.
magnesium is oxidised, 4 electrons leave 2 atom of magnesium and each iodine atom gains one electron, so the iodine is reduced
the resulted compound is a salt, magnesium iodide, MgI2