Problem
When you push a pull request (PR) to a version control system (VCS) provider that is experiencing a service disruption, the triggered plan in HCP Terraform or Terraform Enterprise (TFE) may fail. The plan will not automatically re-run when the VCS provider recovers, and there is no direct way to re-trigger the failed plan for that specific commit.
Cause
During the service disruption, the webhook from the VCS provider that initiates the plan either fails to reach or is not processed correctly by HCP Terraform or TFE. Because the platform already registered a terminal status (failed) for that commit, it will not attempt to run a new plan for the same commit hash after the disruption is over.
Solutions
To resolve this, you must create a new event that HCP Terraform or TFE can process to trigger a new plan. The following solutions are ordered from most to least recommended.
Solution 1: Recreate the Pull Request
This is the cleanest and most recommended option. Delete and recreate the PR on the VCS provider. This action generates a new PR event, which allows HCP Terraform or TFE to see the change as a new request and create a new plan.
Solution 2: Run a Speculative Plan Locally
HCP Terraform and TFE's remote backend supports running speculative plans for local configurations. This allows you to preview the plan results without affecting the PR's status checks in the VCS provider.
- Check out the branch that represents the desired configuration locally.
-
Configure the backend in your Terraform configuration and run
terraform init. - Run
terraform planto execute a speculative plan remotely in HCP Terraform or TFE.
This method does not change check results in the VCS, but it does allow you to preview the plan results.
Solution 3: Add an Empty Commit
You can add an empty commit to the PR branch to trigger a new plan. This approach may have undesirable side effects, such as adding noise to the commit history. Recreating the PR or using the remote backend is typically a cleaner solution.
To create an empty commit, run the following command.
$ git commit --allow-empty -m "Trigger new plan"
Solution 4: Amend the Most Recent Commit
As a last resort, you can amend the most recent commit and force-push the changes. Depending on your branching workflow, this may allow you to keep a cleaner history while still starting a new plan.
This is not recommended if you are collaborating with others on the same branch. If the branch is primarily your own working branch, you can perform the following steps.
First, check out the branch locally and amend the most recent commit.
$ git commit --amend <your changes>
Next, force-push the amended commit to the branch.
$ git push --force