A renewable energy analytics company uses Terraform to manage its Google Cloud infrastructure across multiple projects. During a recent operational incident, an engineer manually modified server instance types and firewall rules directly in the Google Cloud Console. The automated CI/CD pipeline subsequently failed during execution due to state drift between live resources and version-controlled Terraform code. The cloud architecture team must resolve the configuration drift while ensuring long-term IaC governance and compliance. Which strategy should the cloud architect recommend?
- Update the Terraform configuration files to reflect any intended console modifications, run terraform plan to inspect differences, execute terraform apply to reconcile live state with code, and restrict direct Console edit permissions.Cevap
- BAllow manual Cloud Console modifications for emergency incidents and run terraform refresh in the CI/CD pipeline to automatically overwrite repository configuration files with live state.
- CDelete the remote state file stored in the Cloud Storage backend and execute terraform init to regenerate state directly from active Google Cloud resources.
- DGrant the Owner primitive IAM role to the deployment service account to bypass backend state locking errors and force infrastructure updates.
Cevap
Reconcile configuration drift by updating Terraform HCL code to match valid changes or executing terraform apply to revert unauthorized edits, while restricting direct Cloud Console mutation access through IAM least privilege.
The correct approach enforces Infrastructure as Code best practices by reconciling code and live infrastructure, then enforcing least-privilege IAM controls so all future changes flow through automated pipelines.
Adım Adım Çözüm
Anahtar Kavram
Building and Managing Infrastructure as Code (IaC)