Today, we’re excited to announce the general availability of a new feature that automatically cancels plan-only Terraform runs triggered by pull requests in version control systems (VCS) for HCP Terraform and Terraform Enterprise. This enhancement helps customers avoid the backlog of multiple runs caused by new commits pushed to a branch, ultimately speeding up the application delivery process.
When integrated with a VCS, HCP Terraform can automatically initiate a Terraform run to perform a plan operation whenever a pull request (PR) is created in the repository. However, when team members push new commits to the same branch, it can lead to a queue of Terraform runs, causing delays and inefficiencies. With the automatic cancellation of plan-only runs, you can now easily cancel any unfinished runs for outdated commits by selecting the option in your organization’s settings.
This blog will show you how to set up this feature and see it in action.
» Managing organization speculative plan settings
To view and manage an organization’s speculative plan settings, click Settings, followed by General under Version Control, then view the Manage speculative plans part of the page.
Once the organization setting is enabled, HCP Terraform will cancel ongoing or pending speculative plans if new commits are received on the same branch.
» Run details page
When a newer commit gets pushed to the same branch, users will see a message mentioning that the run was automatically canceled.
» Updated VCS status checks
For non-aggregated status checks, Terraform now shows a different message for auto-canceled plan that differs from the normally canceled one (which would show “Terraform plan canceled”).
For aggregated status checks, Terraform now includes a count of automatically canceled runs in the aggregated result, separating it from the count of manually canceled runs.
Also, in the aggregated status page, Terraform now includes a message saying that the run has been auto-canceled using the same message that it would send for non-aggregated status checks.
» Aggregated status page
When more than one run is automatically canceled for a commit, Terraform will display an alert in the “Resources to be changed” section as a reminder that the section may not reflect a complete result if all the runs of the commit were to reach completion. You can toggle “Hide automatically canceled plans” in the check box shown below:
» Getting started
These enhancements to HCP Terraform and Terraform Enterprise reflect our ongoing commitment to helping customers maximize their infrastructure investments and speed up application delivery by optimizing plan-only Terraform runs managed through the VCS workflow.
To learn more about these features, visit our page on automatically canceling plan-only runs. If you are new to Terraform, sign up for HCP Terraform and get started for free today.