TrademarkTrademark
Features
Documentation

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.
Sebastian StadilJune 5, 2025Updated March 31, 2026
Terraform Notifications in Microsoft Teams
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 plan can 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 plan enable 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:

  1. 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.
  2. 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.

  3. Trigger the Script from Terraform: You can use Terraform's local-exec provisioner (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 a terraform plan or terraform apply command, 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"
fi

Example (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.

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.

About the author
Sebastian StadilCEO 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.