Yuccas are very adaptable plants. They can be found anywhere from rocky deserts and badlands, to coastal sands. You can even find some yucca plants in subtropical and semi-temperate zones. Yucca plants are pollinated specifically by yucca moths, which is a really interesting fact. Yucca moths transfer the pollen to the flower of another, but at the same time, lays an egg in the flower where they’ve transferred the pollen. The moth larva then feeds on the developing seeds, but leaves just enough for a new plant to grow.
https://www.inaturalist.org/observations/5957415