Article · part of a guide
Terraform Notifications in Microsoft Teams
Integrate Terraform with Microsoft Teams & get real-time run, policy-check & drift alerts in your channel with a simple setup guide with message examples.

Key takeaways
- Sending Terraform plan, apply, and failure notifications into a Microsoft Teams channel applies ChatOps principles for faster feedback and better visibility.
- Notifications in Teams reduce context switching, centralize a searchable audit trail of events, and enable teams to address errors and drift sooner.
- The DIY approach uses a Teams Incoming Webhook plus a script (PowerShell or Python) triggered from a CI/CD pipeline after plan or apply.
- The DIY approach gives full control but requires setup, scripting, and ongoing maintenance of webhook URLs and notification logic.
- Platforms such as Scalr offer built-in notification systems that let you select Microsoft Teams and define triggering events through a user interface.
When a Terraform run kicks off or a plan finishes, someone usually needs to know. If your team already lives in Microsoft Teams, the obvious place for that signal is the channel you're already watching. Pushing Terraform notifications straight into Teams is a common way to apply ChatOps: the run talks to you where you work, instead of in a log you have to go check.
Why Integrate Terraform with Teams? The ChatOps Advantage
The basic idea is to relay key events from Terraform operations into a Teams channel: the start of a plan, the plan output itself for review, a successful apply, or a failure. That keeps the people who care about a change aware of it as it happens. But you get more than plain alerting. Here's what running notifications this way buys you:
- Visibility and faster feedback: Real-time updates on infrastructure changes keep the whole team current. A notification for a
terraform plancan show the proposed changes right away for review, and a failure notification lets the team jump on the issue instantly. - Less context switching: Instead of monitoring a separate dashboard or email inbox, engineers get the information they need on the platform where they're already collaborating, so they stay focused on their work.
- Collaboration and a centralized audit trail: Discussion around an infrastructure event can happen directly in the Teams thread where the notification appears. That thread becomes a searchable record of who saw what, when, and what was decided. If a plan shows an unexpected change, the team can discuss it and decide on next steps right there.
- A path to richer ChatOps: While this post focuses on notifications, they are often the first step toward more advanced ChatOps. In a more sophisticated setup, a notification about a pending plan could be followed by approval actions directly within Teams, triggering the
apply. - Proactive Issue Resolution: Immediate notifications of errors or unexpected drift detected by a
planenable teams to address problems before they escalate or impact end-users.
Setting Up Terraform Notifications in Microsoft Teams: The DIY Approach
For teams looking to implement this themselves, the typical process involves using Microsoft Teams' Incoming Webhook functionality:
-
Create an Incoming Webhook in Teams:
- Navigate to the desired channel in Microsoft Teams.
- Click on the ellipsis (...) menu and select "Connectors."
- Search for "Incoming Webhook" and click "Add," then "Configure."
- Provide a name for your webhook (e.g., "Terraform Notifications") and optionally upload an icon.
- Click "Create." Copy the unique webhook URL provided. You'll need it to send messages.
-
Prepare a Script to Send Notifications: You'll need a script that Terraform can trigger. This script will take Terraform output (or custom messages) and send it to the Teams webhook URL. This can be done using various languages; PowerShell or Python are common choices.
-
Trigger the Script from Terraform: You can use Terraform's
local-execprovisioner (for resource-specific events, though less common for general run notifications) or, more typically, integrate this scripting into your CI/CD pipeline (e.g., Jenkins, GitLab CI, GitHub Actions). After aterraform planorterraform applycommand, your CI/CD script would call your notification script with the relevant status message.
Example (Conceptual - CI/CD script snippet):
# After terraform apply
if [ $? -eq 0 ]; then
./send_teams_notification.sh "Terraform apply successful for staging environment." "$TEAMS_WEBHOOK_URL"
else
./send_teams_notification.sh "ERROR: Terraform apply FAILED for staging environment." "$TEAMS_WEBHOOK_URL"
fiExample (Conceptual - Python):
import json
import requests
def send_teams_notification(message, webhook_url):
payload = {
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "Terraform Notification",
"sections": [{
"activityTitle": "Terraform Operation Update",
"activitySubtitle": message,
"markdown": True
}]
}
try:
response = requests.post(webhook_url, data=json.dumps(payload), headers={'Content-Type': 'application/json'})
response.raise_for_status()
except requests.exceptions.RequestException as e:
print(f"Error sending Teams notification: {e}")
# Usage: send_teams_notification("Terraform plan initiated for production.", "YOUR_WEBHOOK_URL")Example (Conceptual - PowerShell):
param (
[string]$Message,
[string]$WebhookUrl
)
$payload = @{
"@type" = "MessageCard";
"@context" = "http://schema.org/extensions";
"themeColor" = "0076D7"; # Blue, or choose based on status (e.g., red for failure)
"summary" = "Terraform Notification";
"sections" = @(
@{
"activityTitle" = "Terraform Operation Update";
"activitySubtitle" = $Message;
"markdown" = $true
}
)
}
Invoke-RestMethod -Uri $WebhookUrl -Method Post -Body (ConvertTo-Json $payload) -ContentType 'application/json'While this DIY approach offers complete control, it does require setup, scripting, and ongoing maintenance of the webhook URLs and notification logic.
The Simplified Route: Specialized Platforms
If you'd rather not own the scripts, some CI/CD and infrastructure automation platforms handle the integration for you. Scalr, for example, has a built-in notification system: instead of writing custom scripts and tracking webhook URLs by hand, you pick Microsoft Teams from a list of notification services, authenticate, and choose which Terraform events should fire an alert, all through a user interface. You end up with one less pipeline to maintain, and the events still land in an auditable record. If you're weighing that option, current plans are on the pricing page.
Which route should you pick?
If you want full control and can absorb the maintenance, build the webhook integration yourself with the scripts above. If you'd rather skip the scripting, use a platform like Scalr that supports Teams natively. Both get the run's status in front of the people who need it while there's still time to act on it.
Frequently asked questions
How do I send Terraform notifications to Microsoft Teams?
The DIY route is to create an Incoming Webhook in the target Teams channel, write a small script in PowerShell or Python that posts a message card to the webhook URL, and call that script from your CI/CD pipeline after terraform plan or apply. The script takes the run's status message and sends it to the channel as a formatted card.
Why send Terraform run notifications to a Teams channel?
It applies ChatOps principles: engineers see plan output, successful applies, and failures in the channel they already watch, instead of checking a separate dashboard or inbox. Discussion happens in the notification's thread, which becomes a searchable audit trail, and immediate failure or drift alerts let the team act before problems escalate.
Can I get Terraform alerts in Teams without writing custom scripts?
Yes. Some infrastructure automation platforms have built-in notification systems. In Scalr, for example, you pick Microsoft Teams from a list of notification services, authenticate, and choose which Terraform events should fire an alert, all through the UI, so there is no webhook script to write or maintain.
What are the downsides of the DIY webhook approach for Terraform notifications?
It gives you full control, but you own the setup and upkeep: writing and maintaining the notification scripts, tracking webhook URLs, and keeping the notification logic wired into every pipeline. That maintenance burden is the main reason teams switch to a platform with native Teams support.
About the author

CEO at Scalr
Sebastian Stadil is the CEO of Scalr with 15+ years of DevOps experience. He started with AWS in 2004 and advised early Microsoft Azure and Google Cloud.
Part of this guide
25 sheets
CI/CD and GitOps for Terraform & OpenTofu
- Migrating GitHub Actions from an S3 Backend to Scalr
- Terraform Testing: terraform test, tofu test, Terratest
- Custom Hooks for Terraform and OpenTofu: Pre-Plan, Post-Apply, and the Hooks Registry
- Integrating Terraform with Backstage
- The No-Nonsense Guide to ArgoCD
- Top 10 Continuous Delivery Tools
- Top 10 GitOps Tools: A Comprehensive Guide
- Everything you need to know about using Terraform or OpenTofu with Slack
- Using Terraform with GitLab
- Key DevOps Metrics You Should Be Tracking
- Terraform and OpenTofu with Dependabot
- The Complete Guide to DevOps Monitoring Tools: Choosing the Right Solution for Your Infrastructure
- Top Jenkins Alternatives & Specialized IaC Tools
- Why You Should Use Dependabot with Terraform and OpenTofu
- Mastering Terraform at Scale: A Developer's Guide to Reliable Infrastructure
- Integrating Terraform Events w/ AWS EventBridge
- How to use the Azure DevOps Terraform Provider
- Deploying your infrastructure with Scalr and GitHub Actions
- Terraform Configuration Ingestion
- Setting up Scalr & Azure DevOps Part 3 - Add Azure credentials
- Setting up Scalr & Azure DevOps Part 3 - Execute Your Terraform Code and Create a Workspace
- Setting up Scalr & Azure DevOps Part 1 - Picking a Workflow
- Terraform Cost Estimation in 2021: The Definitive Guide