0
0
Terraformcloud~10 mins

Auto-approve flag and its danger in Terraform - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Auto-approve flag and its danger
Start terraform apply
Check auto-approve flag
Skip prompt
Apply changes
Finish
Finish
Terraform apply checks if auto-approve is set. If yes, it skips confirmation and applies changes immediately. If no, it asks for user confirmation before applying.
Execution Sample
Terraform
terraform apply -auto-approve

# Applies changes without asking for confirmation
This command runs terraform apply and skips the confirmation prompt, applying changes immediately.
Process Table
StepAuto-approve FlagUser PromptAction TakenResult
1YesSkippedApply changes immediatelyInfrastructure updated without confirmation
2NoShownWait for user inputUser confirms or cancels
3NoUser confirmsApply changesInfrastructure updated after confirmation
4NoUser cancelsAbort applyNo changes made
💡 Execution stops after changes are applied or user cancels.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3Final
auto_approveunsettruefalsefalsefalse
user_promptunsetskippedshownshownshown
apply_actionnoneappliedwaitingappliedaborted
infrastructure_stateunchangedupdatedunchangedupdatedunchanged
Key Moments - 2 Insights
Why is skipping the confirmation prompt dangerous?
Because changes are applied immediately without user review, mistakes or unintended changes can happen, as shown in step 1 of the execution_table.
What happens if the user cancels when auto-approve is not set?
The apply is aborted and no changes are made, as shown in step 4 of the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the action taken when auto-approve is set to Yes?
AAbort apply
BWait for user confirmation
CApply changes immediately
DShow error
💡 Hint
Refer to step 1 in the execution_table where auto-approve is Yes.
At which step does the user have a chance to cancel the apply?
AStep 1
BStep 4
CStep 2
DStep 3
💡 Hint
Look at the execution_table rows where user cancels the apply.
If auto-approve is false, what variable tracks whether the user prompt is shown?
Auser_prompt
Bapply_action
Cauto_approve
Dinfrastructure_state
💡 Hint
Check variable_tracker for user_prompt values when auto_approve is false.
Concept Snapshot
terraform apply -auto-approve skips confirmation prompt
Danger: changes apply immediately without review
Without auto-approve, user must confirm before apply
Use auto-approve carefully to avoid unintended changes
Best practice: avoid auto-approve in production
Full Transcript
When you run terraform apply, it usually asks you to confirm before making changes. If you add the -auto-approve flag, it skips this confirmation and applies changes right away. This can be dangerous because you might apply changes you did not intend. Without auto-approve, Terraform waits for your confirmation, and you can cancel if needed. The key variables are auto_approve which controls skipping prompt, user_prompt which tracks if confirmation is shown, apply_action which shows if changes are applied or aborted, and infrastructure_state which shows if infrastructure is updated. Always be careful using auto-approve to avoid mistakes.