Problem
Occasionally when a Pull Request (PR) is pushed to a VCS server and the VCS provider experiences a service disruption, it may cause the triggered Terraform plan to fail. The plan will not automatically re-run when the VCS provider recovers and there is no direct way to re-run the plan in Terraform Enterprise (TFE) or Terraform Cloud (TFC).
Solutions
Recommended option: Recreate the Pull Request (PR)
Delete and re-create the PR on the VCS provider. This will allow TFE/TFC to see the change as a new PR and create a new plan.
Alternative option #1: Use the remote backend
TFE/TFC’s remote backend supports running speculative plans for local configurations remotely within TFE/TFC. To run a relevant speculative plan:
- Check out the branch that represents the desired configuration locally
-
Configure the backend and run
terraform init
. - Run
terraform plan
.
This method doesn’t change check results in the VCS, but does allow previewing the plan results.
Alternative option #1: Execute an empty commit
Add an empty commit to the PR branch to trigger a new plan. This may have undesirable side effects, so deleting and re-creating the PR or using the remote backend is typically cleaner.
Last resort: Amend a commit
If neither of those is an option, another possible workaround is to amend the most recent commit and force push. Depending on how your branching workflow is designed, this may allow you to keep a cleaner history and still start a new plan.
This is not recommended if you’re collaborating with many people on the same branch, but if the branch is primarily your working branch, check out the branch locally and do:
$ git commit --amend <your changes>
$ git push --force