0
0
Terraformcloud~10 mins

Drift detection in CI/CD in Terraform - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Terraform before running drift detection.

Terraform
terraform [1]
Drag options to blanks, or click blank then click option'
Ainit
Bapply
Cplan
Ddestroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' before initialization causes errors.
Confusing 'plan' with initialization.
2fill in blank
medium

Complete the code to create a Terraform plan that detects drift without applying changes.

Terraform
terraform [1] -detailed-exitcode
Drag options to blanks, or click blank then click option'
Avalidate
Bapply
Cplan
Ddestroy
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' applies changes instead of detecting drift.
Using 'destroy' removes resources, not detecting drift.
3fill in blank
hard

Fix the error in the command to detect drift by returning a detailed exit code.

Terraform
terraform plan [1] -detailed-exitcode
Drag options to blanks, or click blank then click option'
A-auto-approve
B-refresh=true
C-refresh=false
D-input=false
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-refresh=false' disables state refresh, missing drift.
Using '-auto-approve' is for apply, not plan.
4fill in blank
hard

Fill both blanks to create a CI/CD step that runs drift detection and fails if drift is found.

Terraform
terraform [1] -detailed-exitcode || exit [2]
Drag options to blanks, or click blank then click option'
Aplan
Bapply
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'apply' applies changes instead of detecting drift.
Exiting with 0 means success even if drift exists.
5fill in blank
hard

Fill all three blanks to define a Terraform workflow step that initializes, refreshes state, and detects drift.

Terraform
terraform [1] && terraform plan [2] -detailed-exitcode || exit [3]
Drag options to blanks, or click blank then click option'
Ainit
B-refresh=true
C1
D-auto-approve
Attempts:
3 left
💡 Hint
Common Mistakes
Skipping initialization causes errors.
Not refreshing state misses drift detection.
Exiting with 0 ignores drift.