terraform apply and Confirmation
What you'll learn: How to actually provision your infrastructure with terraform apply and understand its built-in safety mechanisms.
Making Your Infrastructure Real
After running terraform plan to preview changes, you execute them with terraform apply. This is the command that creates, updates, or deletes cloud resources to match your configuration files.
Think of it like ordering items online: terraform plan shows your shopping cart, but terraform apply is when you hit "Place Order" and changes actually happen.
The Confirmation Prompt
By default, when you run terraform apply, Terraform shows you the same plan output you'd see from terraform plan, then asks for explicit confirmation:
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value:
You must type exactly "yes" to proceed. This is a safety feature preventing accidental infrastructure changes. Typing "y", "yeah", or anything else will abort the operation.
Skipping Confirmation with Auto-Approve
For automated workflows (like CI/CD pipelines), the interactive prompt won't work. Use the -auto-approve flag:
terraform apply -auto-approve
This immediately executes changes without asking. Use it carefully—there's no undo button for deleted resources!
What Happens During Apply
Once confirmed, Terraform executes the changes sequentially, respecting dependencies between resources. You'll see real-time progress as each resource is created, modified, or destroyed. After completion, Terraform updates the state file to reflect the current infrastructure.
Key Takeaway: terraform apply executes infrastructure changes after showing you a plan and requiring explicit "yes" confirmation; use -auto-approve in automation but only when you trust the plan is safe.