A global media streaming organization currently manages its core Google Cloud Virtual Private Cloud (VPC) subnets and Compute Engine template deployments using legacy Google Cloud Deployment Manager deployments. The enterprise platform team is executing a strategic migration to standardize all infrastructure automation on Terraform. The Cloud Architect must establish a state migration workflow that imports existing live resources into Terraform without destroying active workloads or causing configuration drift, while ensuring automated CI/CD execution complies with Google Cloud identity and state management security best practices. Which migration and operational workflow should the Cloud Architect recommend?
- AExport existing Deployment Manager manifests to local disk, configure a remote Terraform state backend using a Cloud Storage bucket, and grant the CI/CD pipeline service account the primitive Owner role (roles/owner) on the target project to ensure terraform import bypasses granular permission checks.
- Define equivalent HCL resource declarations in Terraform, configure a remote Cloud Storage backend with object versioning and state locking enabled, authenticate the automated CI/CD pipeline using short-lived Service Account impersonation via Workload Identity Federation, and execute terraform import commands for existing resources.Cevap
- CDefine equivalent HCL resource declarations, store state files locally within the CI/CD build worker directory using a Git commit hook to sync state back to Cloud Source Repositories, and execute gcloud deployment-manager deployments delete with the ABANDON flag prior to running terraform apply.
- DGrant the deployment service account the Service Account Admin role (roles/iam.serviceAccountAdmin) across the organization hierarchy, download static JSON service account keys into the CI/CD pipeline secrets, and execute terraform apply to recreate all managed resources from scratch.
Cevap
Define equivalent HCL resource declarations in Terraform, configure a remote Cloud Storage backend with object versioning and state locking enabled, authenticate the automated CI/CD pipeline using short-lived Service Account impersonation via Workload Identity Federation, and execute terraform import commands for existing resources.
The recommended approach combines remote state governance in Cloud Storage with state locking and object versioning, keyless pipeline authentication using Workload Identity Federation, and non-destructive state ingestion via terraform import. This ensures active live resources managed by Cloud Deployment Manager are seamlessly mapped into Terraform management without service downtime, while enforcing Google Cloud security standards.
Adım Adım Çözüm
Anahtar Kavram
Terraform Remote State Locking, Resource Import, and Workload Identity Impersonation
Tahmini Süre:2m 30s