Blog Continuous Compliance Financial Management

Integrating with Terraform Cloud Run Tasks

Joseph Spurrier

2 min read

Last updated on February 4th, 2023 at 3:04pm

The HashiCorp team released Run Tasks as a beta feature for Terraform Cloud to allow organizations to add in additional steps between the plan and apply stages of a Terraform job. We were excited to work with their team during the beta to show how we could integrate into the process to show information about the environment before the Terraform resources kicked off.

Run Tasks reaches out to partner solutions using a webhook to notify when a job is running and then provides APIs that the solution can reach in a callback to provide a clickable URL, status (passed or failed), as well as a message that is displayed back to the user.

For our integration, we wanted to provide two event hooks that our customers could utilize in their jobs. The first integrates with our Savings Opportunities, which shows the monthly forecast on a project as well as the available cost savings opportunities. This is helpful if you want to see the monthly forecast before the resources are created. If you have the Team & Governance package, you can also enable Cost Estimation to see the estimated cost of the resources. This allows you to see the impact of the resources on your current environment.

The second hook integrates with Compliance, and shows the number of compliance findings on a project, throwing an error if there are any critical findings. Terraform Cloud allows you to select enforcement levels of either advisory (failed tasks show as informational) or mandatory (failed tasks prevent Terraform from continuing) so you can select either when setting up the hooks. This is helpful if you want to prevent creating resources unless the environment is secure.

Below is an example of the integration in Terraform Cloud.

If you would like to try out out the integration, you can follow our deployment guide on our Support Center. The source code for the integration is available on GitHub in our repository kionsoftware/terraform-cloud-run-tasks.

About the Author

Joseph Spurrier

Joe was previously the CTO at Kion.

Start your cloud operations journey.

Request a demo today,