A global enterprise is establishing an automated Infrastructure as Code (IaC) pipeline to provision Cloud Spanner databases and Cloud Storage buckets across multiple operational regions. During automated CI/CD runs, concurrent pipeline executions occasionally attempt to modify the same environment simultaneously. The lead architect must ensure that remote Terraform state operations prevent race conditions and allow state recovery if accidental deletion occurs. Which provisioning approach best satisfies these requirements?
- Configure the Terraform backend to store the state file in a Google Cloud Storage bucket with Object Versioning enabled, allowing native object locking to manage concurrency.Cevap
- BMaintain state files in unversioned local runner storage and execute custom gcloud synchronization scripts at the end of every pipeline run.
- CReplace the global database requirement with regional Cloud SQL instances to avoid needing remote state locking during provisioning.
- DEncrypt the state storage bucket with Customer-Supplied Encryption Keys (CSEK) to automatically enforce single-writer access locks.
Cevap
The team should store the Terraform state in a Google Cloud Storage backend with Object Versioning enabled to leverage native state locking and preserve state history.
The correct strategy uses Google Cloud Storage as a remote Terraform backend with Object Versioning enabled. The GCS backend natively supports state locking using Google Cloud Storage object locking capabilities, ensuring that concurrent pipeline runs cannot mutate the state simultaneously while providing history recovery.
Adım Adım Çözüm
Anahtar Kavram
Terraform State Management and Storage Backend Provisioning
Tahmini Süre:1m 30s