Robert E. Lee in the Mexican War
When the United States went to war with Mexico in 1846, Lee won laurels on the staff of Major General Winfield Scott, who commanded the American forces that invaded Veracruz and captured Mexico City. As an engineer, Lee helped Scott find ways around Mexican strongpoints or to capture them.
This experience undoubtedly played an important role during the Civil War, when he was always looking for a way to get at those people over there, the Federal armies that he often thwarted. Breveted three times for gallantry in Mexico, Lee crossed the nearly impassible hardened lava beds of the Pedregal in storm and darkness to inform his commander of the position of Scotts advance troops on the other side. He then crossed the inhospitable area again, guiding Scotts follow-on troops to surprise and defeat the Mexican force at Contreras. Scotts estimation of Capt. Lee could not have been higher; one observer called it, almost idolatrous.
https://www.historynet.com/robert-e-lee