What happens if `terraform apply` fails halfway?
AdvancedConceptWorkflow and CLI
Answer
There is no rollback. Resources that succeeded stay created and are recorded in state; failed ones are not (or are marked tainted if creation partly succeeded). Re-running apply continues from where it stopped. If the state backend itself fails to save, Terraform writes errored.tfstate locally; recover it with terraform state push errored.tfstate.
More on Workflow and CLI
What does `terraform init` do?BeginnerWhat does `terraform plan` do?BeginnerWhat does `terraform apply` do and what is `-auto-approve`?BeginnerWhat does `terraform destroy` do?BeginnerWhat do `terraform fmt` and `terraform validate` check?BeginnerWhy save a plan with `-out` and apply that file?Intermediate