How do I setup env0 to use the same state file even if I'm deploying resources to different accounts?

How to centralize my state management to one account


As you deploy your infrastructure across many different target cloud accounts, you may want to have a centralized location for all the state files that need to be maintained and managed.

How To
In Terraform, when preparing your backend config it is important to utilize one of the many options to help ensure your backend resides in the same account. For example, with s3, you can utilize the role_arn and bucket to help ensure that we will authenticate into a singular AWS account and use the same bucket for all of your infrastructure state files.

See the below backend configuration example:

backend"s3" {
# env0 will chain from the deployment role configured in the project -
# this means you need to setup trust between the deployer role and the role
# defined below
## (optional)
#external_id = specified in env0 through ENV0_TERRAFORM_BACKEND_CONFIG=external_id=<your external id>


The example above uses an assume role, but you can also consider configuring AWS profiles using Custom Flows (env0.yaml).



If you'd like more information, please feel free to reach out to us through our website chat or email us at