Terraform on AWS: Nonprod and Production Environments · Foundations: Layout, State, Providers and Organization

Project Layout: modules/, envs/ and tfvars

Organise a Terraform repository so the same module code is shared across nonprod and production without copying it.

Members can save this page, take notes and track progress. See membership · Sign in

What you'll build

The directory tree used throughout this course: a reusable modules/ layer, two environment roots (envs/nonprod and envs/prod) that each manage their own state, and per-environment values in terraform.tfvars.

platform/
├── modules/
│   ├── vpc/          # VPC, subnets, NAT
│   ├── ecs-service/  # ECS Fargate service + autoscaling
│   ├── rds/          # PostgreSQL database
│   └── ...
└── envs/
    ├── nonprod/
    │   ├── main.tf         # calls modules, provider, backend
    │   ├── variables.tf
    │   ├── outputs.tf
    │   └── terraform.tfvars
    └── prod/
        ├── main.tf         # same module calls, different tfvars
        ├── variables.tf
        ├── outputs.tf
        └── terraform.tfvars

Premium course

Keep reading with a membership

The rest of this lesson, its practice questions and the whole Terraform on AWS: Nonprod and Production Environments course are part of the membership.

See plans Sign in

Open in the app to mark lessons complete, take notes and track your progress.

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake