Configure Terraform for Deploy Change Investigator
Send infrastructure changes as deployment webhooks to track them
Track Terraform infrastructure changes by sending deployment webhooks when terraform apply completes.
Before you begin
Deploy Change Investigator setup: Deploy webhook integration created in AI SRE. Go to Deploy Change Investigator to create the webhook endpoint.
Terraform access: Permission to modify Terraform configurations or CI/CD pipelines that run Terraform.
Deploy webhook URL: Deploy webhook URL from the AI SRE integrations page.
Integration approaches
Send Terraform deployment webhooks using one of these methods:
CI/CD wrapper (recommended): Send webhooks from the CI/CD pipeline after
terraform apply.Local provisioner: Use the
local-execprovisioner in your Terraform configuration.Terraform Cloud: Use run notifications.
Option 1: CI/CD wrapper (recommended)
Send webhooks from your CI/CD pipeline after Terraform completes.
GitHub Actions
name: Terraform Deploy
on:
push:
branches: [main]
env:
TF_WORKSPACE: production
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.9.0
- name: Terraform Init
run: terraform init
- name: Terraform Apply
run: terraform apply -auto-approve
- name: Send deploy webhook to AI SRE
if: success()
run: |
curl -X POST "${{ secrets.AISRE_DEPLOY_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-d '{
"services": [{
"service": "infrastructure-${{ env.TF_WORKSPACE }}",
"version": "${{ github.sha }}"
}],
"environments": ["${{ env.TF_WORKSPACE }}"],
"changeId": "${{ github.run_id }}",
"status": "SUCCESS",
"deployedBy": "${{ github.actor }}",
"deployTimestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
"metadata": {
"tool": "terraform",
"workspace": "${{ env.TF_WORKSPACE }}"
}
}'
- name: Send failure webhook
if: failure()
run: |
curl -X POST "${{ secrets.AISRE_DEPLOY_WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-d '{
"services": [{
"service": "infrastructure-${{ env.TF_WORKSPACE }}",
"version": "${{ github.sha }}"
}],
"environments": ["${{ env.TF_WORKSPACE }}"],
"changeId": "${{ github.run_id }}",
"status": "FAILURE",
"deployedBy": "${{ github.actor }}",
"deployTimestamp": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'",
"metadata": {
"tool": "terraform"
}
}'Option 2: Local provisioner
Use a null_resource with local-exec provisioner to send webhooks from Terraform.
Create webhook notification resource
Use webhook notification
Set webhook URL securely
Using environment variable
Using terraform.tfvars (add to .gitignore)
Using Terraform Cloud variables
Store the webhook URL as a sensitive workspace variable:
Navigate to workspace Settings, then select Variables
Add a variable:
Key:
deploy_webhook_urlValue: Webhook URL
Category: Terraform variable
Sensitive: Yes
Extract service information
From outputs
Define outputs to list deployed services:
From resource tags
Provisioner considerations
Run only on create
Handle errors
Testing webhooks
Test from CI/CD
Run an apply in your pipeline and confirm the webhook reaches AI SRE:
Run
terraform applyin CI/CDCheck pipeline logs for webhook execution
Navigate to AI SRE, then select Integrations
Click the More icon on the DEPLOY integration
Select Debug
Verify the webhook appears
Test local provisioner
Run an apply locally and confirm the webhook reaches AI SRE:
Run
terraform applylocallyCheck the console output for curl execution
Verify the webhook in the AI SRE Debug view
Troubleshooting
Best practices
Follow these practices to keep Terraform change tracking reliable:
Store webhook URLs securely: Use environment variables, Terraform Cloud sensitive variables, or CI/CD secrets.
Use the CI/CD wrapper: It is more reliable than provisioners for webhook notifications.
Separate infrastructure changes: Track infrastructure deployments separately from application deployments.
Version consistently: Use the commit SHA or a timestamp for infrastructure change versions.
Next steps
Go to Deploy Change Investigator to complete the setup.
Go to AI Agent RCA to understand how the AI agent uses change detection during incidents.
Go to Configure Jenkins to set up webhooks in Jenkins pipelines.
Last updated
Was this helpful?