I wouldn't say it was just that. The Ukrainians realized they were in trouble in 2014 when Russia lopped off Crimea, and ordered a painful introspective to highlight all the weaknesses of their military.
They spent 8 years overhauling their military and learning from invited western forces to prepare for an invasion that they hoping beyond all would never come. And it paid off in spades.
They spent 8 years overhauling their military and learning from invited western forces to prepare for an invasion that they hoping beyond all would never come. And it paid off in spades.