AWS, Cloud Computing, DevOps

3 Mins Read

Real-Time AWS CloudFormation Stack Monitoring with Slack Notifications

Voiced by Amazon Polly

Introduction

Monitoring AWS CloudFormation stack events is crucial to track deployments, updates, and failures. Instead of manually checking AWS Console or Amazon CloudWatch logs, you can automate notifications to a Slack channel.

This post will guide you through setting up an AWS Lambda function that listens to Amazon SNS messages from AWS CloudFormation and sends notifications to Slack.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

How It Works?

  1. An Amazon SNS Topic is created to receive AWS CloudFormation stack events.
  2. AWS Lambda function subscribes to this Amazon SNS topic and processes messages.
  3. The function extracts details like stack name, resource status, and physical resource ID.
  4. If the event is important (e.g., failure or rollback), it is formatted and sent to Slack.

Setting Up the Slack Notification Bot

You must set up a Slack bot with a webhook URL to send messages to a Slack channel. You can follow the guide in this reference to create a Slack webhook and obtain the required URL.

AWS CloudFormation Template

This template provisions:

  • An AWS IAM Role for the Lambda function.
  • AWS Lambda function to process SNS events and send Slack notifications.
  • An Amazon SNS Topic to receive AWS CloudFormation stack events.
  • AWS Lambda Subscription to Amazon SNS for automatic invocation.

AWS Lambda Function Code

This function:

  • Parses Amazon SNS messages from AWS CloudFormation.
  • Extract stack details and resource statuses.
  • Sends notifications to Slack for relevant events.

Conclusion

With this setup:

  • AWS CloudFormation stack events are pushed to an Amazon SNS topic.
  • The AWS Lambda function listens to events and posts critical updates to Slack.
  • You get real-time notifications for failures and rollback actions.

This solution improves visibility and response time for AWS CloudFormation changes in your AWS environment.

Drop a query if you have any questions regarding AWS CloudFormation and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFrontAmazon OpenSearchAWS DMSAWS Systems ManagerAmazon RDS, and many more.

FAQs

1. How do I set up the Slack Webhook URL?

ANS: – You need to create a Slack app and generate an incoming webhook URL. Follow these steps:

  1. Go to Slack API Apps
  2. Click “Create New App”
  3. Select “From Scratch” and provide an app name
  4. Enable “Incoming Webhooks”
  5. Add a new webhook and choose a Slack channel
  6. Copy the generated webhook URL and store it in the AWS Systems Manager Parameter Store under /CFN/slack/webhook/url

2. Can I filter which AWS CloudFormation events trigger Slack notifications?

ANS: – Yes, you can modify the AWS Lambda function to exclude events like CREATE_COMPLETE or UPDATE_COMPLETE and only send failure or rollback notifications.

WRITTEN BY Deepak S

Deepak S works as a Research Intern at CloudThat. His expertise lies in AWS's services. Deepak is good at haunting new technologies and automobile enthusiasts.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!