An enterprise organization manages multiple Google Cloud projects across production and non-production environments using Terraform within a centralized CI/CD pipeline. Engineers report intermittent deployment failures caused by concurrent pipeline executions modifying state simultaneously, and security audits identified Terraform state files containing sensitive data stored locally on transient build runners. You need to redesign the Infrastructure as Code (IaC) architecture to align with Google Cloud security and operational best practices. Which strategy should you recommend?
- Configure a dedicated Cloud Storage bucket per environment with Object Versioning enabled as the Terraform remote backend, enforce state locking via Cloud Storage native locking mechanisms, and restrict bucket access using fine-grained IAM roles granted to the CI/CD execution service account.Cevap
- BStore state files in a local directory on the CI/CD runner host and execute a post-deployment script that uploads state snapshots to a Cloud Storage bucket without object versioning.
- CConfigure a single shared Cloud Storage backend for all environments, disable Object Versioning to control storage costs, and grant the primitive Owner role to all deployment pipelines to ensure full resource management rights.
- DStore state files in a central Git repository and grant the Service Account Admin role (roles/iam.serviceAccountAdmin) to the deployment pipeline service account to dynamically generate service account keys during execution.
Cevap
Configure a dedicated Cloud Storage bucket per environment with Object Versioning enabled as the Terraform remote backend, enforce state locking via Cloud Storage native locking mechanisms, and restrict bucket access using fine-grained IAM roles granted to the CI/CD execution service account.
Configuring a dedicated Cloud Storage bucket with Object Versioning enabled as the Terraform remote backend guarantees state persistence, prevents state corruption from concurrent runs via native GCS state locking, allows point-in-time state recovery through object versions, and secures state contents by applying fine-grained IAM roles to the automated pipeline service account.
Adım Adım Çözüm
Anahtar Kavram
Terraform Remote State Management and Security Best Practices in GCP
Tahmini Süre:2m 0s