Interview Prep/Terraform/Workflow and Providers

The same configuration must create a VPC in `us-east-1` and a DR copy of a bucket in `eu-west-1`. How do you do it with one root module?

IntermediateScenarioWorkflow and Providers
Answer

Situation read → One root module, two regions: that's the textbook use for provider aliases.

What I'd do →

  1. Define a default provider and an aliased one.
  2. Point specific resources at the alias with provider =.
provider "aws" {
  region = "us-east-1"
}

provider "aws" {
  alias  = "dr"
  region = "eu-west-1"
}

resource "aws_s3_bucket" "dr" {
  provider = aws.dr
  bucket   = "acme-logs-dr"
}

Why → Each provider configuration is bound to one region/account; aliases let one run manage both without separate stacks.

Interview tip → Mention that if modules need the alias, you pass it explicitly via the providers map.

All Terraform questions Roadmap: Terraform

More on Workflow and Providers