Skip to content

Terraform

Terraform State Management

The terraform state should be stored in a remote backend. You can use AWS S3 bucket for storing the Terraform state. Make sure to configure the backend in your Terraform configuration files. The S3 bucket should be created manually from AWS console. The bucket name should be unique across all AWS accounts, so use a name that includes your team name or some unique identifier. Whole team must be setup to use the same S3 bucket for storing the Terraform state. The bucket should be created in the root account (organization management account).

Since we will need to support multiple environments (e.g., dev, staging, prod), you should create separate folders in the S3 bucket for each environment. For example, you can create folders like dev, staging, and prod in the S3 bucket. You can use Terraform workspaces to manage different environments. Each workspace will have its own state file, which will be stored in the corresponding folder in the S3 bucket.

Terraform State Repository Pull Request Status Checks

The pull request status checks should validate the Terraform templates and also check that the templates are properly formatted. Status check should fail if the templates are not properly formatted and/or if there is any syntax errors in the template.