I have various environments (in the form of workspaces) in Terraform (dev / staging / prod) on google cloud. They mostly share the same code regarding infrastructure. The changes are in settings for the size of the envs. So far so good. But, when it comes to DNS, all the envs share the exact same code and even the same state as there is only one DNS zone and I don't see a reason to use more zones (maybe I'm wrong).
This comes with some issues: when I make some changes in one environment I need to import it in the others. And when I want to destroy an environment then the DNS zone gets destroyed as well.
I think there must be a better way to handle DNS in multi environment setup.
I need DNS in all envs because when I add a public facing service in any of the envs then its IP needs to be associated with a new record in the zone.
Edit: I am now trying to use various different zones (
google_dns_managed_zone) to link to subdomains for each environment. That way I can have only the resource needed in each environment. But now the issue is that each zone is automatically assigned to new NS servers. So I should either update the registrar's list of name servers or I should add those to the main zone (I tried, both way works). But that is getting complicated and not so efficient.