Skip to content

apply

Usage

  • terraform apply is a command used in the Terraform infrastructure-as-code tool to apply changes to the infrastructure defined in a Terraform configuration.
  • It reads the configuration files and creates, updates, or deletes the resources necessary to match the desired state.
  • The apply command should be used after running terraform plan to preview the changes that will be made.
  • Running apply without first running plan can result in unintended changes to the infrastructure.
  • Planning modes and planning options apply as used for terraform plan command

Saved plan mode

  • terraform init -input=false to initialize the working directory.
  • terraform plan -out=tfplan -input=false to create a plan and save it to the local file tfplan.
  • terraform apply -input=false tfplan to apply the plan stored in the file tfplan.

Options

include general options from terraform plan

-auto-approve

  • The auto-approve option in terraform apply skips the interactive plan approval step, making it useful for automation scripts.
  • Example: terraform apply -auto-approve
  • This option bypasses safety checks and should only be used in confident situations.