If you are using S3 as the backend for your state management in Terraform, then you can create environment specific configuration files where you store the
region among other things to be pulled in automatically when switching environments.
Step 1 – Create environment specific configs
dev.conf file with the following content:
Step 2 – Set the
state.tf file, specify the following:
Step 3 – Run init with
Now you can init your Terraform with the new config file.
You can easily change the
dev.conf to be
prod.conf or whichever environment you specify.