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.
terraform apply # plan, confirm, applyterraform apply tfplan.binary # apply a saved planterraform apply -auto-approve # skip the prompt (CI only)terraform apply -replace=aws_instance.web # force recreation of one resourceIn CI, save a plan during review with terraform plan -out, then apply exactly that file.
SecurityDo not use
-auto-approveagainst 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.