Skip to main content

Terraform Apply

The terraform apply command executes a plan, creating, updating, or destroying real infrastructure to match your configuration. It records each successful change in the state file.

What Is Terraform Apply?

Apply plans, shows the diff, asks for confirmation, then calls the provider APIs. If it fails halfway, state keeps everything that succeeded, and a re-run does only the remaining work.

Bash
terraform apply # plan, confirm, apply
terraform apply tfplan.binary # apply a saved plan
terraform apply -auto-approve # skip the prompt (CI only)
terraform apply -replace=aws_instance.web # force recreation of one resource

In CI, save a plan during review with terraform plan -out, then apply exactly that file.

Security

Do not use -auto-approve against production without a prior human review. Treat saved plan files as secrets.

Frequently Asked Questions

Does apply always show a plan first?

Yes, unless you pass a saved plan file. With no file it plans and asks for yes, and -auto-approve skips the prompt.

How do I recreate one resource?

Use terraform apply -replace=ADDRESS. It replaces the deprecated terraform taint command.

Found a mistake, an outdated step or a broken link?