Blogs

Integrating AWS SNS with Microsoft Teams for CloudWatch Log Notifications

Purpose of the article: In this article, we will demonstrate how to connect with the Simple Notification Service (SNS) from AWS to push notifications to Microsoft Teams. We will achieve this by configuring appropriate access to CloudWatch logs using Identity and Access Management (IAM) roles, and utilizing Amazon EventBridge for scheduling events.

Intended Audience: This guide is intended for cloud architects , DevOps, system administrators, IT operations teams, security engineers, developers, technical support teams who need to integrate AWS SNS with Microsoft Teams for CloudWatch log notifications.

Tools and Technology: AWS services ( Simple Notification Services (SNS), Identity Access Management (IAM), Amazon EventBridge, AWS Glue, CloudWatch logs)

Keywords: IAM,SNS, CloudWatch, Amazon EventBridge, AWS Glue

Objectives:

In this article, we will demonstrate how to connect with the Simple Notification Service (SNS) from AWS to push notifications to Microsoft Teams. We will achieve this by configuring appropriate access to CloudWatch logs using Identity and Access Management (IAM) roles and utilizing Amazon EventBridge for scheduling events.

Technology:

AWS Services (Simple Notification Services (SNS), Identity Access Management (IAM), Amazon EventBridge, AWS Glue, CloudWatch logs)

  • Simple Notification Service (SNS): Amazon SNS is a fully managed messaging service provided by AWS that enables you to manage the delivery or sending of messages.
  • AWS Glue: AWS Glue is a fully managed ETL service provided by AWS. It is designed to help you to transform data.
  • Amazon EventBridge: Amazon EventBridge is a service from AWS that enables you to build event-driven applications by connecting various services and applications using events.
  • AWS IAM: IAM is AWS Service for managing users, roles and permissions, providing secure control over access to AWS resources.
  • Cloud watch: Cloud watch is AWS monitoring and observability service, collecting and tracking data, providing actionable insights, and triggering automated responses based on predefined rules.

Architecture:

Steps:

Step1- Teams Creation:

Open Microsoft teams & Create Teams.

Select form of a template (Manage a project) and next select what kind of team you need; it should be either public or private.

Enter Team name and click on create. Once the team is created, we will get email address which we need further to create SNS topic. And note down the email address.

Step2-SNS Topic & Subscription Creation:

Open AWS Management Console and go to Simple Notification Service (SNS). Click on Topics then create topic.

  While creating a topic select type as Standard and create topic by providing appropriate name.

After creating the topic, open it and create a subscription. Enter the   topic ARN & Select the protocol type as “Email” and enter the email address that we have copied in Step 1.

Now we will receive a notification in Teams to confirm the subscription. We need to confirm the start of receiving notifications from AWS SNS.

Step3- AWS Glue Script Creation (Test Case):

Create a demo glue job to setup the sending SNS notifications to teams when it’s failing

Open AWS Management Console and go to AWS Glue, create glue job by providing job name and assign IAM role, which will give the access to get CloudWatch logs.

Develop some code inside the script like shown in below screen shot.

Step4- AMAZON EventBridge Rules Creation

Open the AWS Management Console and go to the AMAZON EventBridge and click on the “Rules” tab in the navigation pane.

Select ‘Create Rule’ and enter the “Rule name”, then select Rule type as “Rule with an event pattern” and click on next.

Next enter the Build event pattern details select Event source as” other” and Sample Event as ‘AWS Events’.

Select Creation method as “Custom pattern” and pass the Json showed below. And replace the <GLUE-JOB-NAME> with actual name of the glue job.

{
   “source”: [“aws.glue”],
   “detail-type”: [“Glue Job State Change”],
   “detail”: {
     “jobname”: [“<GLUE-JOB-NAME>”],
     “state”: [“FAILED”, “ERROR”, “STOPPED”]
   }
 }

In Step 3, Select target(s), select target type as “AWS Service” & select “SNS Topic”. We will get all the SNS topics in drop down from the list. We need to select topic which we have created in Step 2.

In Step 4, configure tags. Click on ’next’ and check all details which are mentioned are correct or not and click on ‘Create Rule’.

Monitor the Result

With this, all settings are done. If in any case our glue job stalls or fails, we will get the Teams notification as shown below:

Conclusion:

Connecting AWS SNS to Microsoft Teams allows efficient real-time notifications. By setting up IAM Roles for CloudWatch log access and using Amazon EventBridge for event scheduling, we can ensure that important alerts are reliably sent to our Teams. This integration simplifies monitoring and improves our ability to respond quickly to critical issues.

Advantages

  • Scalability: AWS services like SNS and EventBridge are designed to handle large-scale operations, ensuring the solution can scale as needed.
  • Reliability: Using well-established AWS services ensures a high level of reliability and uptime for notifications.
  • Flexibility: Integrates with other AWS services for enhanced functionality.
  • Scheduled Events: EventBridge can schedule notifications, adding flexibility to the notification system.
  • CloudWatch Integration: By integrating CloudWatch logs, the article provides a way to monitor and trigger notifications based on log events, which is useful for maintaining and troubleshooting applications.

Disadvantages

  • AWS Charges: Using multiple AWS services can incur costs, which may be a concern for small businesses or individuals with limited budgets.
  • Service Downtime: Relying on AWS and Microsoft Teams means that downtime or issues with these services can impact the notification system.

Author Bio:

Picture of Himaja KANCHERLA

Himaja KANCHERLA

Associative Software Engineer - Data Engineering-Analytics

I’m Himaja KANCHERLA, and I've been with MOURI Tech for 9 months as Associate Software Engineer in Data Engineering. Have a good knowledge in AWS, DBT, Python and SQL coding language.

Leave A Comment

Related Post

Purpose to Contact :
Purpose to Contact :
Purpose to Contact :

Purpose to Contact :
Purpose to Contact :
Purpose to Contact :

Purpose to Contact :