One root configuration is deployed to dev and prod, and each environment keeps its state in a different S3 bucket in a different account. The team wants a single committed backend block, no generated or duplicated Terraform files per environment, and no secrets on the command line. How should the pipeline select each environment's bucket?
Choose one.
Partial backend configuration supplies some backend arguments at init time from a file or key/value flags.
The block keeps the shared arguments and leaves bucket out; terraform init -backend-config=prod.s3.tfbackend merges the environment's value in. HashiCorp recommends the *.backendname.tfbackend naming. Override files work mechanically but are per-environment Terraform files, workspaces cannot change the bucket, and variables cannot be used in a backend block.
- List the constraints: one committed block, no per-environment .tf files.
- Recall partial configuration via -backend-config files.
- Reject override files, which are extra Terraform files.
- Reject workspaces, which share the configured bucket.
Exam tip: Different buckets per environment: one block, one .tfbackend file per environment, passed at init.
Terraform Professional: Remote Backends and Remote State — the lesson that teaches this.