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
- In Google Chat, create a new Space or use an existing one.
- Click the dropdown next to the room name → Manage Webhooks.
- Click Add Webhook, name it (e.g.,
AWS Alerts
), and copy the generated Webhook URL.
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
- Go to the AWS Lambda console, click Create Function, choose Author from scratch, Set the runtime to Python 3.x., then choose create.
- Upload
python_code.zip
under Function Code → Upload from .zip file.
- Update the handler name to
lambda_function.lambda_handler
.
Step 4: Test the End-to-End Flow
Manual Test (Lambda)
- Go to your Lambda function and click Test.
- Choose template: SNS Topic Notification.
- Use the default sample SNS event data and test.
Step 5: Create SNS Topic and Subscription
Create SNS Topic
- Go to Amazon SNS → Topics → Create topic.
- Use Standard, give it a name (e.g.,
alert-notifications
), and click Create.
Subscribe Lambda to the Topic
- Go to Subscriptions → Create subscription.
- Set Protocol to
AWS Lambda
. - Select your newly created Lambda function.
- Confirm the subscription and ensure the Lambda function has a trigger from the SNS topic.
Manual Test (SNS)
- In the SNS topic, click Publish message.
- Add a subject and message body, then publish.
- Check your Google Chat space for the alert message.
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!