Skill 6.3.2

Partial configuration and backend migration

Key Concepts

With partial configuration, the backend block omits some or all arguments, which are then supplied with terraform init -backend-config=backend.hcl or -backend-config="key=value", or interactively. This keeps environment-specific values and secrets out of the configuration and lets one configuration use different buckets per environment. Backend credentials should come from environment variables or the platform's credential files.

When you add, change or remove a backend, run terraform init again. Terraform detects the change and asks whether to copy existing state to the new backend; -migrate-state does this explicitly, and -reconfigure switches without migrating. Terraform saves the initialized backend settings in .terraform/terraform.tfstate, which is not the infrastructure state.