A cloud engineering team needs to safely migrate an existing local Terraform state file to a secure Google Cloud Storage (GCS) remote backend with state locking enabled. Arrange the operational steps in the correct sequence to complete this migration.
- 1Provision a private GCS bucket with Object Versioning enabled and uniform bucket-level access enforced.
- 2Add the `backend "gcs"` configuration block specifying the bucket details into the root Terraform module file.
- 3Execute `terraform init` and confirm the prompt to copy existing local state data to the newly configured GCS backend.
- 4Verify the state file exists in the GCS bucket and safely remove the leftover local `terraform.tfstate` file.
Cevap
The correct operational sequence begins with provisioning the private GCS bucket with Object Versioning enabled, adding the GCS backend configuration block to the Terraform module, executing terraform init to migrate the state data, and finally verifying remote state creation before deleting the local state file.
Safely migrating Terraform state requires provisioning the remote GCS bucket with Object Versioning first, defining the backend block in the Terraform code second, executing terraform init to copy existing local state into GCS third, and removing local state files fourth to maintain a single source of truth.
Adım Adım Çözüm
Anahtar Kavram
Terraform GCS Remote Backend State Migration
Tahmini Süre:1m 30s