0
0
Terraformcloud~20 mins

Drift detection in CI/CD in Terraform - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Terraform Drift Detection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
What is drift detection in Terraform CI/CD pipelines?

In a Terraform-based CI/CD pipeline, what does drift detection mean?

ADetecting changes in infrastructure that were made outside of Terraform management
BAutomatically applying all pending Terraform changes without review
CRunning Terraform plan only when code changes are pushed
DBacking up Terraform state files to a remote location
Attempts:
2 left
💡 Hint

Think about what happens if someone changes the cloud setup manually, not through Terraform.

💻 Command Output
intermediate
1:30remaining
Output of Terraform plan detecting drift

What output will Terraform show if the actual infrastructure has drifted from the last applied state?

Terraform
terraform plan
AShows 'No changes. Infrastructure is up-to-date.'
BShows a list of changes Terraform will apply to fix the drift
CThrows an error about missing state file
DAutomatically applies changes without confirmation
Attempts:
2 left
💡 Hint

Terraform plan shows what it will do to match the real infrastructure to the code.

🔀 Workflow
advanced
2:00remaining
Best place to add drift detection in CI/CD pipeline

Where in a CI/CD pipeline should you add drift detection to catch manual changes early?

ABefore applying changes, run 'terraform plan' to detect drift
BOnly after applying changes, run 'terraform apply' without plan
CSkip drift detection and rely on manual audits
DRun drift detection only on production environment after deployment
Attempts:
2 left
💡 Hint

Think about catching problems before making new changes.

Troubleshoot
advanced
2:00remaining
Why does Terraform plan show no changes despite drift?

You suspect drift in your infrastructure, but running terraform plan shows no changes. What could cause this?

ATerraform does not support drift detection
BTerraform automatically fixed the drift before plan
CTerraform state file is outdated or corrupted
DThe cloud provider API is down
Attempts:
2 left
💡 Hint

Think about what Terraform uses to compare infrastructure state.

Best Practice
expert
2:30remaining
Automating drift detection in multi-environment CI/CD

In a multi-environment setup (dev, staging, prod), what is the best practice to automate drift detection?

AIgnore drift detection in non-production environments
BOnly run drift detection manually when issues are reported
CRun 'terraform apply' daily to force sync all environments
DSchedule regular 'terraform plan' runs with state refresh for each environment and alert on drift
Attempts:
2 left
💡 Hint

Think about proactive monitoring and alerting.