An engineering team needs to migrate their local Terraform state file to a centralized Google Cloud Storage (GCS) bucket for collaborative management. Arrange the operational steps in the correct sequential order to complete this state migration.
- 1Add a `backend "gcs"` configuration block inside the Terraform root module pointing to the target Cloud Storage bucket.
- 2Run `terraform init` in the working directory to initialize the new backend configuration.
- 3Approve the interactive confirmation prompt to copy the existing local state file into the Cloud Storage bucket.
- 4Run `terraform plan` to verify that the remote state accurately reflects the live infrastructure without pending changes.
Cevap
The correct operational order begins with adding the `backend "gcs"` configuration block, executing `terraform init`, confirming the state transfer prompt, and finishing with `terraform plan` to verify remote state synchronization.
Safely migrating local Terraform state to a remote GCS backend requires defining the backend block in code, running `terraform init` to initiate migration, agreeing to transfer existing state data, and running `terraform plan` to confirm remote state integrity.
Adım Adım Çözüm
Anahtar Kavram
Terraform Remote State Migration to Google Cloud Storage