Yes having the deterrent is strategically beneficial, but working toward it paints a huge target on your back, while you need to pay for development, endure sanctions, etc.
Any state considering such weapons development already knows this. So this war is not new information.
And it's far from over yet.
Iran could very well end up cut off from the strait as rival gulf states build pipelines, rail, and drone defenses. (Sure this kind of long term thinking is not characteristic of the actors involved, but politics change easier around Iran than inside it.)