Question

Difficulty: MediumImplementing Infrastructure as Code using Terraform and Deployment Manager

Your engineering team is migrating legacy infrastructure management to an automated CI/CD pipeline using Terraform across multiple Google Cloud projects. You need to configure state storage and pipeline access permissions to ensure concurrency safety, auditability, and adherence to least-privilege security principles. Which architecture configuration should you implement?

  1. Store the state file in a Cloud Storage backend with Object Versioning enabled, and configure the automated pipeline to impersonate a dedicated service account using the Service Account Token Creator role.Answer
  2. B
    Store the Terraform state file in the application source control repository, and execute the automated pipeline using a service account assigned the primitive Owner role.
  3. C
    Store the state file in an unversioned Cloud Storage bucket, and grant the pipeline service account the Service Account Admin role to ensure it can manage all identity resources during execution.
  4. D
    Store the Terraform state in local execution storage, and configure the pipeline script to request GCP regional quota increases automatically after a state apply failure occurs.

Answer

Store the state file in a Cloud Storage backend with Object Versioning enabled, and configure the automated pipeline to impersonate a dedicated service account using the Service Account Token Creator role.
Configuring a Cloud Storage backend with Object Versioning provides automatic lock acquisition during execution and state recovery options. Combining this backend with service account impersonation via short-lived tokens ensures enterprise security and operational reliability without exposing static key files.

Step-by-Step Solution

1
Establish secure remote state management
Configured Google Cloud Storage backend with Object Versioning enabled.
Google Cloud Storage natively supports object locking to prevent concurrent state modifications and object versioning to allow rolling back to previous state snapshots if corruption occurs.
2
Configure pipeline authentication and authorization
Pipeline uses short-lived credentials via service account impersonation.
Granting the Service Account Token Creator role to the pipeline runner allows short-lived token generation, avoiding exported JSON key management while preserving least privilege.

Key Concept

Terraform Remote State locking, GCS Versioning, and Service Account Impersonation
Estimated Time:1m 30s
Rate this question