Terraform
Automatically cancel plan-only runs
This topic describes how to automatically cancel plan-only Terraform run triggered by pull requests in the VCS.
Introduction
When connected to a VCS, HCP Terraform can automatically start a Terraform run that performs a terraform plan
operation when someone creates a pull request (PR) in the repository. Refer to Connecting to VCS for additional information.
When team members push new commits to the same branch, HCP Terraform starts new run that performs a terraform plan
operation. But as team members push new commits, the queue of Terraform runs can cause delays and reduce efficiency.
You can enable the Automatically cancel speculative plans for outdated commits option in the organization's settings screen so that HCP Terraform automatically cancel unfinished plan-only runs in VCS workflows.
Configure automatic cancellation
- Log in and click on your organization.
- Click Settings in the sidebar navigation.
- Under the Version Control group of settings, click General.
- Enable the Automatically cancel speculative plans for outdated commits option under the Manage speculative plans section.
- Click Update settings.
After enabling the option, HCP Terraform cancels ongoing or pending speculative plans when new commits are received on the same branch.
Automated cancellation notifications
When the Automatically cancel speculative plans for outdated commits option is enabled, HCP Terraform notifies you about plan-only runs that are canceled as a result of the setting. Notifications appear in the following screens:
Run details page. Refer to Viewing and Managing Runs for additional information.
VCS status checks. When the Non-aggregated status checks option is enabled in the version control settings, the notification explicitly states when a plan has been canceled automatically.
When the Aggregated status checks option is enabled, HCP Terraform includes canceled plans in the result and identifies them separately from manually canceled plans.
Refer to VCS Status Checks for additional information.
- Aggregated status page. HCP Terraform prints the cancelation message in the aggregated status page in the Resources to be changed section. The section may not reflect a complete result if all runs associated with the commit reach completion.