X-TFE-Notification-Signature header) using the notification token Kestrel generates at connect time, and Kestrel verifies the signature before evaluating workflows.
Prerequisites
- Organization Admin role in Kestrel
- A Terraform Cloud (or Terraform Enterprise) organization with at least one workspace
- A Terraform Cloud API token with access to the organization — a team token or organization token is recommended over a user token
Setup
1
Create an API token
In Terraform Cloud (
app.terraform.io), go to your organization’s Settings → API tokens (or Account Settings → Tokens for a user token). Create a team token for a team that has the workspace permissions your workflows need (queue plans, apply runs, lock workspaces, manage variables). Copy the token — it is shown only once.2
Connect in Kestrel
- Navigate to Integrations → Terraform Cloud in your Kestrel dashboard.
- Paste your API token.
- Enter your Organization name (e.g.
my-org). - Optionally set a custom API base URL for Terraform Enterprise (defaults to
https://app.terraform.io/api/v2). - Click Connect Terraform Cloud — Kestrel validates the token against your organization and generates a notification token for webhook verification.
3
Register workspace notifications (for triggers)
Actions work as soon as the token is connected. To have Terraform Cloud events trigger workflows, add a notification configuration to each workspace you care about:
- On the Kestrel Terraform Cloud integration page, copy the Webhook URL and the Notification token.
- In Terraform Cloud, go to Workspaces and open the workspace you want events from. Notifications are a per-workspace setting — you won’t find them under Organization Settings.
- In the workspace’s sidebar, open Settings → Notifications and click Create a Notification.
- Choose the Webhook destination, set the URL to the copied webhook URL, and paste the notification token as the Token.
- Select the run events you want (Created, Planning, Needs Attention, Applying, Completed, Errored).
- If the workspace has health assessments enabled (HCP Terraform Plus/Premium), a Health Events section also appears — select Drifted and Check Failed there to enable drift triggers. On workspaces without health assessments, these options are not shown.
- Repeat for each workspace that should trigger workflows.
Drift events require health assessments to be enabled on the workspace (Terraform Cloud Plus/Premium). Health assessment notifications (
assessment:drifted, assessment:check_failure) are only sent for workspaces with assessments turned on.How It’s Used
In Workflows
Trigger blocks (webhook):- Run Created — fires when a new run is queued on a workspace
- Run Planning — fires when a run starts planning
- Run Needs Attention — fires when a plan finishes and the run awaits confirmation (the moment to route an approval)
- Run Applying — fires when a run starts applying
- Run Completed — fires when a run applies successfully or finishes as planned-and-finished
- Run Errored — fires when a run fails (plan error, apply error, or policy hard-fail)
- Drift Detected — fires when a workspace health assessment detects infrastructure drift from state
- Assessment Check Failed — fires when a workspace health assessment fails to run
{{signal.workspace}}, {{signal.run_id}}, {{signal.run_status}}, {{signal.organization}}, and {{signal.run_url}} for downstream steps.
Action blocks:
- List Workspaces / Get Workspace — inventory (lock state, execution mode, Terraform version, resource counts)
- Lock Workspace / Unlock Workspace — block or allow runs during incidents and maintenance windows
- Force-Unlock Workspace — recover a workspace stuck by a crashed run’s lock (gate behind an Approval node)
- List Runs / Get Run — run history and a run’s status plus planned adds/changes/destroys (great for Slack notifications and approval context)
- Create Run (Plan) — queue a plan run on a workspace, optionally auto-apply
- Create Destroy Run — queue a destroy plan (gate behind an Approval node)
- Apply Run — confirm and apply a run awaiting confirmation (gate behind an Approval node for production)
- Discard Run / Cancel Run — discard a pending plan or interrupt an in-progress run
- Wait for Run — poll a run until it reaches a terminal state (applied, errored, discarded, canceled) and branch on the result
- Get State Outputs — read the workspace’s current state outputs (sensitive values are redacted) to wire infrastructure values into later steps
- List Variables / Set Variable — inspect and update workspace Terraform/environment variables (sensitive values are never returned; gate Set Variable behind an Approval node)
- Get Drift Assessment — check the latest health assessment result for drift
- Investigate Terraform — run a read-only AI investigation across workspaces, runs, state outputs, variables, and drift
{{signal.workspace}} and {{signal.run_id}} from the trigger.
Example (approval gating — the flagship Terraform flow): When a run needs attention on a production workspace, fetch the run’s planned changes, post them to Slack with approve/reject buttons, then Apply Run on approval or Discard Run on rejection.
Example (drift): When drift is detected, run an AI investigation, queue a plan run to preview remediation, and open a Jira ticket with the findings.
Example (incident): When a run errors, investigate the failure with AI and page on-call via PagerDuty with the summary and run URL.
Disconnecting
- Navigate to Integrations → Terraform Cloud
- Click Disconnect
- Confirm the disconnection