Monitoring and alerting are crucial components of a production-ready AWS setup. In this guide, I’ll show you how to forward AWS CloudWatch alarm notifications (from services like ECS, EC2, and ALB) directly to a Google Chat room using AWS SNS and a Lambda function, perfect for teams that rely on Google Workspace rather than Slack or other messaging tools.

Use case: My ECS service scales up when CPU or memory exceeds 75%. I want to be notified instantly via Google Chat, not just email.

🚧 The Challenge

AWS CloudWatch can trigger alarms and use Amazon SNS to notify users. However, Google Chat is not a supported SNS target (only email, Lambda, SQS, HTTP/S, etc.). So, how do we bridge this gap?

The solution:

CloudWatch Alarm → SNS → Lambda → Google Chat Webhook

Prerequisites

To complete this integration, you’ll need:

  • An AWS account with permissions to create SNS topics and Lambda functions
  • A Google Chat room with a webhook URL
  • Basic knowledge of Python and AWS Lambda

Step 1: Create a Google Chat Webhook

  1. In Google Chat, create a new Space or use an existing one.
  2. Click the dropdown next to the room name → Manage Webhooks.
  3. Click Add Webhook, name it (e.g., AWS Alerts), and copy the generated Webhook URL.

Image description

Image description

Image description

Step 2: Create and Prepare a Lambda Function

We’ll write a Python-based AWS Lambda function that uses the httplib2 library to send alerts to Google Chat.

Python Code (lambda_function.py)

from httplib2 import Http
from json import dumps

def lambda_handler(event, context):
    url = ""  # Replace with your Google Chat webhook
    message = {'text': event['Records'][0]['Sns']['Message']}
    headers = {'Content-Type': 'application/json; charset=UTF-8'}

    http_obj = Http()
    response = http_obj.request(
        uri=url,
        method='POST',
        headers=headers,
        body=dumps(message)
    )
    return response

Using any Linux Machine, do the following

🔹 Install Dependencies and Package the Code

mkdir -p python/lambda
cd python/lambda
vi lambda_function.py  # Add your code above here and save the file
pip3 install httplib2 -t .
pip3 install requests -t .
zip -r python_code.zip .

⚠️ If pip3 isn’t available, install it:

  • Ubuntu/Debian: sudo apt install python3-pip
  • RHEL/CentOS: sudo dnf install python3-pip

Step 3: Deploy the Lambda Function

  1. Go to the AWS Lambda console, click Create Function, choose Author from scratch, Set the runtime to Python 3.x., then choose create.

Image description

  1. Upload python_code.zip under Function Code → Upload from .zip file.

Image description

Image description

  1. Update the handler name to lambda_function.lambda_handler.

Image description


Step 4: Test the End-to-End Flow

Manual Test (Lambda)

  1. Go to your Lambda function and click Test.
  2. Choose template: SNS Topic Notification.
  3. Use the default sample SNS event data and test.

Image description

Image description

Step 5: Create SNS Topic and Subscription

Create SNS Topic

  1. Go to Amazon SNS → Topics → Create topic.
  2. Use Standard, give it a name (e.g., alert-notifications), and click Create.

Image description

Image description

Subscribe Lambda to the Topic

  1. Go to Subscriptions → Create subscription.
  2. Set Protocol to AWS Lambda.
  3. Select your newly created Lambda function.
  4. Confirm the subscription and ensure the Lambda function has a trigger from the SNS topic.

Image description

Image description

Image description


Manual Test (SNS)

  1. In the SNS topic, click Publish message.
  2. Add a subject and message body, then publish.
  3. Check your Google Chat space for the alert message.

Image description
Image description


Final Thoughts

This setup allows you to integrate AWS alerts with Google Chat, ensuring critical system events reach your team in real-time—even if you’re not using Slack or Teams.

You can now attach the SNS topic to any CloudWatch alarm or event rule, including:

  • ECS Service scaling
  • EC2 instance high CPU usage
  • ALB 5XX error spikes

🔗 Related Reading

If you found this helpful, follow me for more real-world AWS DevOps tutorials.

Let’s build more resilient cloud-native systems—one alert at a time!

DevOps #CloudEngineer #GoogleChat #Automation #SNS #Lambda #AWSLambda #Integration #Alerting #Cloudwatch #Hangout #AWSCommunityBuilders