Question

Difficulty: MediumImplementing Infrastructure as Code using Terraform and Deployment Manager

An enterprise logistics company is transitioning its Google Cloud infrastructure automation to HashiCorp Terraform. To support collaborative deployment pipelines across multiple engineering teams, the lead architect must establish a centralized state management architecture that prevents concurrent state modification conflicts and enables recovery if state files are corrupted or accidentally deleted. Which strategy satisfies these operational requirements following Google-recommended best practices?

  1. Configure a Terraform Google Cloud Storage remote backend referencing a dedicated GCS bucket with Object Versioning enabled.Answer
  2. B
    Store state files within local version control repositories shared among developers to handle concurrent updates through Git merge operations.
  3. C
    Assign the primitive Owner role to all automated CI/CD service accounts to bypass state file locking checks during parallel pipeline executions.
  4. D
    Request a regional Compute Engine API quota increase prior to each deployment pipeline run to resolve state lock timeout errors.

Answer

Configure a Terraform Google Cloud Storage remote backend referencing a dedicated GCS bucket with Object Versioning enabled.
Configuring the standard `gcs` remote backend in Terraform allows teams to store state in Google Cloud Storage. The GCS backend natively supports state locking using Cloud Storage strong consistency and object generation preconditions, preventing concurrent operations from corrupting state. Enabling Object Versioning on the bucket ensures historical state file versions are retained for point-in-time recovery.

Step-by-Step Solution

1
Identify state locking and concurrency control requirements for multi-developer Terraform environments on GCP.
Recognize that a remote backend is required rather than local state storage.
Local state storage cannot safely handle multi-user concurrent pipeline executions.
2
Evaluate GCP native storage options for Terraform remote backend integration.
Select the GCS backend (`backend "gcs"`), which leverages Cloud Storage object generation metageneration preconditions for atomic state locking.
GCS backend natively provides lock acquisition and release without requiring external database locks.
3
Evaluate data protection and state recovery mechanisms.
Enable Object Versioning on the GCS state bucket.
Object Versioning ensures that previous state snapshots are preserved, allowing rapid rollback if a state file becomes corrupted.

Key Concept

Terraform Remote Backend with Google Cloud Storage and State Locking
Estimated Time:1m 30s
Rate this question