Instantly triage failed Terraform runs in Slack and Jira
When an HCP Terraform run fails, we instantly explain what broke in your infrastructure Slack channel and open a Jira bug for the platform team to fix.
Trigger this workflow from an HCP Terraform run notification webhook. In HCP Terraform, open each workspace you want to monitor, go to Settings then Notifications, add a notification configuration of type Webhook that points at this workflow's webhook URL, and scope it to the run errored / failed events. Terraform will then POST to this workflow whenever a run in that workspace errors.
When a webhook arrives, read the run ID and the run status from the notification payload. Only continue for genuine plan or apply failures (an errored run). If the run was user-canceled, force-canceled, or discarded, stop without posting to Slack or opening a Jira ticket, so we do not create noise for runs that never really failed.
Call Show Run on the run to confirm its status and collect the links to its plan and apply. Then call Get Plan JSON Output to read what the plan attempted to change.
Using the run status and the plan, diagnose the most likely cause of the failure and describe it in plain language a teammate can act on, for example a provider authentication error, a missing or invalid variable, a resource that already exists, or a dependency or timeout during apply. Keep it to a short, specific summary rather than a raw log dump.
Post an alert to our infrastructure Slack channel using the Slack Bot Send a Message action. Include the workspace name, the run status, your plain-language diagnosis of the most likely cause, and the links to the run's plan and apply so the team can jump straight to the details.
Open a Jira issue with Create Issue that captures the workspace, a concise summary of the error, and links back to the run. Set the issue type to Bug and assign it to the platform team so the failure is owned and tracked to resolution.
Additional information
What does this prompt do?
- Watches your HCP Terraform workspaces and springs into action the moment a run fails.
- Reads the failed run and its plan, then writes a plain-language explanation of the most likely cause.
- Posts an alert to your infrastructure Slack channel with the workspace, a summary, and links straight to the run.
- Opens a Jira bug assigned to the platform team so the failure is tracked, while skipping runs that were simply canceled or discarded.
What do I need to use this?
- An HCP Terraform (Terraform Cloud) account with the workspaces you want to monitor.
- A Slack workspace and the channel where failure alerts should land.
- A Jira project where new bug tickets should be created.
- A few minutes to add a Terraform notification that points at this workflow and fires on failed runs.
How can I customize it?
- Change which Slack channel receives the failure alerts.
- Point the tickets at a different Jira project, team, or issue type.
- Adjust which run outcomes count as a real failure worth a ticket versus noise to ignore.
Frequently asked questions
Will this create a ticket every time someone cancels a run?
How fast does the alert arrive?
What goes into the Slack alert?
Do I need to write any code?
Can I send alerts to a different team?
Related templates
Stop hunting down failed Terraform runs.
Get an instant, plain-language explanation in Slack and a tracked Jira ticket every time a run fails.