Interview Prep/Terraform/State Backends and Workspaces

Give a pipeline in Account A access to state in a bucket in Account B.

IntermediateScenarioState Backends and Workspaces
Answer

Situation read → Cross-account backend access.

What I'd do →

  1. Create an IAM role in the state account with s3:GetObject, PutObject, DeleteObject (for the lock file), ListBucket on the prefix.
  2. Allow the pipeline role to assume it.
  3. Configure the backend with assume_role.
backend "s3" {
  bucket = "acme-tfstate"
  key    = "app/terraform.tfstate"
  region = "ap-south-1"
  assume_role = { role_arn = "arn:aws:iam::111111111111:role/tf-state-access" }
}

Why → The backend's identity is separate from the provider's, which keeps state access centralised and auditable.

Interview tip → Scope the role to the key prefix per stack.

All Terraform questions Roadmap: Terraform in production

More on State Backends and Workspaces