A DevOps team is configuring Terraform to manage Google Cloud infrastructure for a new application environment. To prevent simultaneous deployments from causing state file corruption and concurrency conflicts, what is the Google Cloud recommended practice for managing the Terraform state backend?
- Configure a central Google Cloud Storage (GCS) bucket backend with object versioning enabled to support automatic state locking.Answer
- BStore state files in an unversioned local directory shared via a network drive so engineers can inspect state files offline.
- CGrant the Owner primitive IAM role to CI/CD service accounts to allow automated pipelines to override state locking errors.
- DApply modifications manually using the Google Cloud Console whenever concurrent Terraform runs encounter state lock failures.
Answer
Configure a central Google Cloud Storage (GCS) bucket backend with object versioning enabled to support automatic state locking.
Configuring a Google Cloud Storage (GCS) bucket as a remote backend allows Terraform to utilize GCS object lock features to block concurrent updates while keeping historical versions of state for disaster recovery.
Step-by-Step Solution
Key Concept
Terraform Remote Backend and State Locking in Google Cloud Storage