apply
Usage
terraform applyis 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
applycommand should be used after runningterraform planto preview the changes that will be made. - Running
applywithout first runningplancan 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=falseto initialize the working directory.terraform plan -out=tfplan -input=falseto create a plan and save it to the local filetfplan.terraform apply -input=false tfplanto apply the plan stored in the filetfplan.
Options
include general options from terraform plan
-auto-approve
- The
auto-approveoption interraform applyskips 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.