How to use `-auto-approve` flag with terraform apply

widget

The terraform apply command is used to apply all changes to the project infrastructure specified in the terraform plan.

Find out more about terraform plan here and more on the different options available for the apply command here.

When run without specifying a plan file, the terraform apply command automatically generates its own action plan. The user is then prompted to approve the described plan. To automatically approve the plan that the terraform apply command will generate, you need to pass it the -auto-approve flag as an argument when you enter the command.

Syntax

The complete command looks like this:

This will allow the terraform apply command to execute the plan without prompting the user for approval.

Should you be using -auto-approve?

Similar behavior is seen when you pass terraform apply a plan file. The command executes and applies changes to your infrastructure without asking for approval from the user. But there is a big difference between the two. If you pass it, a plan terraform apply checks and tallies the changes made to the infrastructure with what is described in the provided plan file. If run along with the -auto-approve flag, the command creates the plan based on the changes made to the infrastructure. This makes using the -auto-approve flag very dangerous because some mistakes might result in permanent loss of data or the destruction of your database. These mistakes will be applied without asking for your approval.

It is, therefore, recommended to always use your own plan file instead of using the -auto-approve flag since it allows you to review all the changes you have made before they are executed.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved