There are multiple ways to configure environment settings in Terraform. This repo evaluates initial four but it has branched out to multiple possible methods with an aim of writing DRY easy to maintain code.
- 1 solution consisting of EC2 web frontend connecting to RDS Postgres backend and an S3 bucket
- 4 environments in main region and a DR in a different region
- The Prod S3 bucket must have 90 day lifecycle policy wheras it's not required on non-prod
- Resources tagged to easily identify different environments
Option 1: Terrafrom TFVars
Option 2: Terraform Workspaces
Option 2b: Terraform Workspaces with autovars
Option 3: Terragrunt
Option 3b: Terragrunt with simplified folder structure and environment config
Option 3c: Terragrunt with bash support and env var usage
Option 3d: Terragrunt with centralised hcl module files
Option 4: Terragrunt and Ansible
How to manage multiple environments with Terraform using workspaces
How to manage multiple environments with Terraform using branches
How to manage multiple environments with Terraform using Terragrunt