Skip to content
Latchkey

terraform apply Command Reference

Execute the planned changes against your real infrastructure.

terraform apply carries out the actions in 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 with no prompt; given no plan it generates one and asks for confirmation unless -auto-approve is set.

Common flags and usage

  • (plan file): apply a saved plan exactly as reviewed
  • -auto-approve: skip the interactive approval prompt
  • -input=false: never prompt (required in CI)
  • -parallelism=N: limit concurrent resource operations
  • -target=ADDR: apply only specific resources

Example

shell
# Apply the exact plan produced earlier in the pipeline
terraform apply -input=false tfplan

# Or apply directly, skipping the approval prompt
terraform apply -input=false -auto-approve -var-file=prod.tfvars

In CI

Prefer applying a saved tfplan over -auto-approve so the change can never drift from review. Keep the Terraform CLI version identical between plan and apply, since the saved plan binary format is version-specific.

Key takeaways

  • Apply a saved plan file in CI so the change exactly matches what was reviewed.
  • -auto-approve skips confirmation for ad hoc or direct applies.
  • Use the same CLI version for plan and apply; the saved plan is version-specific.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →