Initializing the Terraform State S3 Backend
Follow these steps to configure and initialize the Terraform state backend using Atmos, ensuring proper setup of the infrastructure components and state management.
Steps | Actions |
---|---|
Configure Terraform state | atmos workflow init/tfstate -f baseline |
Setting up the Terraform State Backend
This is where we configure and run Atmos. Atmos is a workflow automation tool that we will use to call Terraform which
will provision all the accounts and resources you need to create and manage infrastructure. The Atmos configuration can
be found in the atmos.yaml
.
If you're unfamiliar with atmos, you can read more about it here.
If you look at components/terraform/
, you'll see a bunch of directories. These contain Terraform "root modules" that are provisioned with Atmos. At first they'll only have their vendor files, such as components/terraform/tfstate-backend/component.yaml
.
-
You can use
atmos workflow vendor -f baseline
to vendor all thebaseline
modules, if the Terraform files are not present. You'll want to at least see Terraform files intfstate-backend
andaccount-map
. -
Once you've done that, you can run
atmos workflow init/tfstate -f baseline
to deploy the Terraform Backend.NOTE:it can take a minute for the S3 buckets you created to become available. The workflow will attempt to wait until the bucket is created and available, with a 5-second delay between each check. -
Wait until you see the following prompt
Initializing the backend...
Do you want to migrate all workspaces to "s3"? -
Type
yes
to continue. This will migrate the state from the local backend to the s3 backend.
The IAM User for SuperAdmin will be granted access to Terraform State by principal ARN. This ARN is passed to the
tfstate-backend
stack catalog under allowed_principal_arns
. Verify that this ARN is correct now. You may need to
update the root account ID.