An organization is configuring an automated CI/CD pipeline to deploy infrastructure in Google Cloud using Terraform. The pipeline must store the Terraform state file in a central Google Cloud Storage (GCS) bucket named `corp-tf-state-prod` located within the project `proj-prod-infra`. The pipeline service account will execute `terraform plan` and `terraform apply`. Which TWO configurations or operational steps are required to establish a secure and resilient remote backend implementation according to Google Cloud best practices?
- Configure the Terraform backend block using the `gcs` provider referencing `corp-tf-state-prod` and ensure Object Versioning is enabled on the bucket.Answer
- Authenticate the CI/CD pipeline execution using Workload Identity Federation or short-lived Service Account Impersonation instead of exporting long-lived JSON service account keys.Answer
- CGrant the primitive `roles/owner` role to the pipeline service account at the Organization level to guarantee state lock acquiring permissions across all projects.
- DEnable the Google Cloud Deployment Manager API within the Organization's primary billing account to process backend locking requests.
Answer
The two correct requirements are configuring the Terraform backend block with the `gcs` provider while ensuring Object Versioning is enabled on the GCS state bucket, and authenticating the deployment pipeline using Workload Identity Federation or Service Account Impersonation rather than downloading long-lived service account keys.
Configuring the Terraform `gcs` backend provider alongside GCS Object Versioning establishes native state locking and disaster recovery capabilities. Authenticating the deployment pipeline via Workload Identity Federation or IAM Service Account Impersonation avoids long-lived credentials, aligning directly with Google Cloud security benchmarks for automated infrastructure deployment.
Step-by-Step Solution
Key Concept
Terraform GCS Remote Backend Architecture & Secure Service Account Authentication