Skip to content
Latchkey

terraform apply: Usage, Options & Common CI Errors

The command that actually changes your infrastructure - run it deliberately.

terraform apply executes the actions proposed by a plan. In CI you apply a saved plan file so the change matches exactly what was reviewed; interactively you pass -auto-approve.

What it does

terraform apply provisions, updates, or destroys resources to match the plan. Given a saved plan file it applies it without prompting; given no plan it generates one and asks for confirmation unless -auto-approve is set.

Common usage

Terminal
# Apply a reviewed plan (CI pattern - no prompt, exact change)
terraform apply tfplan

# Apply directly, skipping the approval prompt
terraform apply -auto-approve

# Apply with variables and a parallelism cap
terraform apply -var-file=prod.tfvars -parallelism=10 -input=false

Common error in CI: error creating resource / already exists

Applies commonly fail with "Error: creating EC2 Instance: ... " or "Error: ... already exists" when a resource was created outside Terraform or a prior apply partially succeeded. Fix: import the existing object with terraform import <address> <id> so state knows about it, then re-apply. For partial failures, read the error, fix the root cause (quota, IAM, naming collision), and re-run - Terraform is idempotent and will only finish the unfinished work.

Key options

OptionPurpose
(plan file)Apply a saved plan exactly
-auto-approveSkip the interactive approval
-input=falseNever prompt (required in CI)
-parallelism=NLimit concurrent resource operations
-target=ADDRApply only specific resources

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →