Anony Mous - not a word you have said has indicated that any of what has happened has been "legal" in international terms.
"Announcing what you are going to do" does not make it legal.
"Keeping your word" to do something that is illegal does not make it legal.
Hitting them because they are bad people - which seems to be most of the justification against the Iranian regime (and was the same flawed idea against Saddam in Iraq) does not make it legal (nor, as we saw in Iraq, does it mean things will be "better" soon and the ordinary people necessarily better off).
Remember, it was primarily the USA and UK that defined what was supposed to be "legal" on the international scene after WWII. So WE are supposed to be the ones to uphold international "order", not ride roughshod over it whenever we feel like it. That "ORDER" is supposed to be OURS in origin - based on enlightened, Judeo-Christian, moral principles. (Allegedly.)
Of course, the reality is that we HAVE often just done whatever we wanted, BUT until recently, we have at least tried to show a pretence or slightly use the tools and institutions we ourselves put in place.
We can't blame the "Commies" or the Muslims for the world order that WE established, yet we and our allies are the ones that seem to violate it most blatantly these days!
During the first Iraq crisis Bush Snr went to the UN, during the second Bush Jnr at least made a pretence of going via the UN (with his pet Blair at his side) - but this time?
By allowing Israel to blatantly violate international law repeatedly at will over Gaza and the West Bank, and now Iran - and then on top that, the President of the USA deciding to arbitrarily strike inside another sovereign nation, means all pretence of obeying any kind of rule of law except "I'll do what I want" has gone out of the window. Trump didn't bother to consult Congress before taking action either (naturally).
Now consider how nations opposed to the West (or perhaps more importantly, those who are more neutral, who could be persuaded either way) might react.
Once again, they will see the collective West acting with complete hypocrisy: expecting non-Western nations to abide by treaties and law and the rulings of international bodies, yet ignoring those whenever it sees fit.
The likely response of our enemies? While none can face off against the USA in a direct head-to-head, their advantage is with what is known as "asymmetrical warfare" - many of those states and their populations have the means to sow terror and chaos in the West and against Western assets and people around the world.
Asymmetrical warfare is something which the USA is particularly poorly equipped to handle, as we've seen from conflicts from Vietnam onwards. It doesn't matter how much tech you have or how big your military are, if you can be attacked by kids with AK47s or women with suicide vests, for example.
I really do think that by acting as they do today, the likes of Netanyahu and Trump are sowing the wind (while other major leaders stand around wringing their hands rather than speaking out decisively), and we will all reap the whirlwind.
All this immature talk of the US having "a long memory" and "getting revenge for the Iran hostage crisis" which I'm hearing a lot is also hideously ill-advised. Maybe now, other countries will exercise their "right" to take "revenge" on the USA and the west for their perceived long standing grievances too, since that seems to be the "new world order" Trump is operating in? Maybe the downing of the Iran Air passenger jet by the USS Vincennes in 1988? Or the various war crimes in Iraq, like those at Abu Ghraib? As the old quote goes: "An eye for an eye will leave the whole world blind."
Sheer madness.
And ultimately, it only postpones the inevitable: which is that eventually - maybe in 2 years, maybe in 5, maybe in 10 - some officials will have to get around a table and reach an agreement about what Iran can and can't do with nuclear energy. Monitors will have to go in, checks will have to be done, and so on. The same with other dubious world powers acquiring potential WMD. We can't just keep bombing our way out of it and thinking that solves the issue. It's the only way in the long term, but progress to that end is made massively more complicated by rushing in to use the military now. Sooner or later, if we keep behaving like this a regime that has the bomb, or is on the brink of it, will see how the West acts now and will strike first before it gets struck, because they will know the West cannot be trusted to abide by its own rules.