We have created some AWS infra with terraform. Originally, it was planned to use a single region but now there are some resources that require to be in multiple regions.
So, we would like to rename the provider alias to contain the region name (please, let’s not go into the details about why not use a separate directory for the new region… Let’s focus on the problem):
If we just rename the alias and then update the providers meta-argument of our modules, terraform apply runs and says nothing changed (which seems to be a bug knowing that the old provider alias is not available anymore in the root module and it is stored together with the resources in the state file… see below).
At the same time, when we want to do any change on the resource and run terraform again, it says
Error: Provider configuration not present
Seems terraform stores the provider (including the alias as well) in the state file for each resource:
# terraform state pull|grep provider|head -n3 "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].infra-prod", "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].infra-test", "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].infra-prod",
The only solution that we could find is to pull the state, replace the provider names manually and push it back. This is not something that we would like to do, as part of the infra is in production.
Anyone has any other solution/idea?