Using a HashiCorp Terraform Cloud Run Task Webhook Trigger
Integrate external services into your IaC workflows with HashiCorp Terraform Cloud Run Tasks. Trigger Blink automations with Terraform events using run tasks.
Integrate external services into your IaC workflows with HashiCorp Terraform Cloud Run Tasks. Trigger Blink automations with Terraform events using run tasks.
HashiCorp Terraform Cloud Run Tasks help you integrate external services like security, compliance, and cost management tools into your Infrastructure-as-Code (IaC) workflows. This is especially useful for automating code review using third-party tools.
Now, you can trigger Blink automations with events from Terraform using run tasks. This can be accomplished using a simple webhook trigger. When triggered, a run task sends an API payload to the external service containing information about your Terraform run, like a callback URL that provides a passed or failed status.
By using Terraform Cloud run tasks, Blink makes it easy to add approvals checks via interactive Slack notifications to your Terraform workflows, or create event-based automations triggered by Terraform Cloud to enforce compliance, security, or business requirements.
In this tutorial, you will set up a Terraform Cloud run task for Blink, a no-code automation platform for managing cloud operations workflows. You will configure a Blink integration for Terraform Cloud and create a corresponding run task in your Terraform Cloud organization.
By integrating your Blink and Terraform Cloud accounts, you can unlock a great deal of flexibility as to what you can automate.
Here is a high-level description of the different steps that occur when an event-based workflow in Blink gets triggered by a Terraform Cloud event:
To further illustrate possible automations, here are two common examples for implementing Blink workflows using a trigger from Terraform Cloud run tasks.
One of the simplest, yet most impactful ways of improving your infrastructure provisioning process is to streamline approvals processes. For example, when your team is merging new code to your main branch, you’ll likely need approval from a manager.
During the Pre-plan, Post-Plan, or Apply stages, you can invoke a run task that triggers Blink to send a notification via Slack to a manager, with context about the Terraform run and the option to “Approve” or “Deny” the execution. If you want, you can make this a conditional step. For example, you can configure the Blink workflow to require an approval step only if your operation happens on the main branch. Furthermore, your Blink workflow can include just a simple approval step, or you can add multiple steps across different cloud services.
It’s quick and simple to set up your first Blink automation. Check out this introduction to learn more about Blink automations and event-based workflows you can set up using Terraform Cloud run tasks.
In addition to requiring an approval step as part of your Terraform workflow, you can also introduce third-party tools such as vulnerability scanners, cost management, code scanning, and more into the infrastructure provisioning process. Using Blink, it’s possible to shortcut some of the manual configuration effort required to create efficient workflows using different security tools.
Rapidly create event-based workflows that combine steps across different cloud tools and services. Blink extends your Terraform workflows and automates actions across different cloud services so you can focus on shipping better code faster.
You can find a list of purpose-built automation workflows for Terraform Cloud in the Blink Automation Library.
In order to successfully complete this tutorial, you will need:
Note: You cannot create a run task unless the Automation is published and active, and has at least one step.
The first step is creating and connecting your Terraform Cloud and Blink accounts. This integration generates a unique endpoint URL in Blink. You will use this URL as the Webhook URL when you create a run task in Terraform Cloud.
Here’s how to connect Terraform Cloud from Blink:
1. From your Blink workspace, click Add Automation.
2. Enter Automation name and select in which Pack to place the new Automation.
3. In Type of trigger, select Event-based Automation.
4. Select Terraform Cloud, Run Task Webhook Event > Continue. The Trigger setup dialog box will open.
5. Copy the Webhook URL. You will need this later to create a run task in Terraform Cloud.
Next, you will need to create a Terraform Cloud run task. You will configure this run task with a webhook that serves as an endpoint URL for communication between Terraform Cloud and Blink. When triggered, this run task will initiate the automated approvals process via an interactive Slack notification sent to a Terraform account administrator.
To create a Terraform Cloud Run Task:
1. In Terraform Cloud, go to Workspaces > Select a workspace > Settings > run tasks.
2. Click Create a new Run Task. The Create a Run Task page will open.
3. Enter all values on the Create a Run Task page.
4. Click Create Run Task. Run Tasks will open.
5. Under Available run Tasks, next to Relevant Run Tasks, click +. The Associated Run Task page will open.
6. Under Run Stage, select your desired run stage. The Blink integration works with all run stages. Under Enforcement Level, select Advisory or Mandatory according to your preference. Click Create.
Finally, you need to set up the callback that informs Terraform Cloud a code review has received an approval and is ready to proceed.
In order for the run task to finish successfully, the Blink automation must return a callback request to Terraform Cloud. This can be done using the Terraform Cloud Run Task Callback action.
To set up a Terraform Cloud Run Task Callback:
Blink makes it easy to create event-based workflows. You can create triggers using schedules, polling, if-this-then-that (IFTTT) flows, REST APIs, polling, and many other actions. Whether your automation is triggered in Terraform Cloud run tasks, Slack, or from elsewhere in your cloud, Blink is the fastest way to deliver impactful automations that empower your developer and business teams.
Blink even has an Automation Library with purpose-built workflows for cloud services like AWS, Terraform, and Slack. Blink helps DevOps, SecOps, and FinOps achieve flow in their everyday work, by making it easy to create automations across the cloud platforms and services they use every day.
The best part? The no-code future for cloud operations is available today. Get started with Blink today.
Blink is secure, decentralized, and cloud-native. Get modern cloud and security operations today.