Iraq and Afrghanistan would look like nothing compared to any invasion of Iran. It won't happen at all, never mind not at first.
As for technology, people always fall into the trap of thinking US military technology is unstoppable and unbeatable. Do you know that in the early 2000's the US ran a military wargame with one of their own generals Paul K. Van Riper taking on the role of Iran? Early in the game when the US were trying to pressure them to surrender, he surprised everyone by locating the US carrier strike group with a small boat swarm and then launched a massive cruise missile attack which destroyed 16 warships including an aircraft carrier. This would have added up to 20,000 American servicemen dead in real life. He then sank a number of extra US ships using small boats and suicide attacks.
You know what the response of the people running the wargame was? They stopped the game, restarted with all their assets back in place, and then..
"After the war game was restarted, its participants were forced to follow a script drafted to ensure a Blue Force victory. Among other rules imposed by this script, Red Force was ordered to turn on their anti-aircraft radar in order for them to be destroyed, and was not allowed to shoot down any of the aircraft bringing Blue Force troops ashore.[3] Van Riper also claimed that exercise officials denied him the opportunity to use his own tactics and ideas against Blue Force, and that they also ordered Red Force not to use certain weapons systems against Blue Force and even ordered the location of Red Force units to be revealed.[4]"
https://en.wikipedia.org/wiki/Millennium_Challenge_2002
Now yes in the 18 years since the US have lots more shiny new toys than they had back then, but it's worth remembering that back then the technological advantage was already immense. The point being that technology doesn't hand you certain victory, and a smart, innovative commander can achieve remarkable success even against a much stronger foe. Imagine if that wargame had actually been reality. How do you think the US public would have responded if they'd woken up one morning to hear that they'd just lost more troops in a single day than 9/11 and Pearl Harbour combined? Oh and that one of their symbols of US power, the supercarrier was sitting in peices on the bottom of the sea?