A cloud architect is standardizing an organization's infrastructure automation practices. The team needs to safely transition a local Terraform state file to a centralized Google Cloud Storage (GCS) backend to support team collaboration and state locking. In what order should the architect execute the steps for this migration process?
- 1Provision a dedicated Cloud Storage bucket with object versioning enabled and uniform bucket-level access enforced.
- 2Add a backend "gcs" configuration block specifying the bucket name and state prefix to the Terraform root module.
- 3Execute terraform init and approve the prompt to copy the existing local state to the new Cloud Storage backend.
- 4Remove the local terraform.tfstate file and enforce least-privilege IAM permissions on the GCS bucket.
Cevap
The correct sequence of steps is: first provision the GCS bucket with versioning, next define the gcs backend configuration block, then execute terraform init to migrate the state file, and finally delete the local state file while restricting bucket permissions.
Establishing a GCS remote backend requires provisioning the prerequisite Cloud Storage bucket first, declaring the backend gcs block in configuration code second, running terraform init to trigger state migration third, and completing post-migration local cleanup and access restriction fourth.
Adım Adım Çözüm
Anahtar Kavram
Remote Infrastructure State Management and Migration in Terraform