AWS, Cloud Computing

3 Mins Read

Send Slack Notifications for AWS IAM Policy Changes Using AWS Lambda and Amazon EventBridge

Voiced by Amazon Polly

Introduction

In today’s cloud-native world, managing and securing user permissions is one of the most critical aspects of maintaining a strong security posture. AWS Identity and Access Management (IAM) provides a powerful way to control access to AWS resources. However, the same power can be risky if IAM changes go unnoticed. An overly permissive policy, a mistakenly altered access level, or an unauthorized change can lead to potential security breaches.

For organizations operating in regulated environments or following best practices like least privilege, monitoring AWS IAM policy changes is not just helpful, it’s essential. Often, AWS IAM policies evolve, especially in dynamic development environments where different teams might deploy and iterate frequently. This means new permissions are being granted, existing ones modified, and sometimes even sensitive ones accidentally exposed. Without visibility into these changes, auditing, controlling, and responding to threats becomes difficult.

Automation is the key to bridging this gap. Using AWS native services like AWS CloudTrail, Amazon EventBridge, and AWS Lambda, you can create a proactive notification system that informs you in real-time whenever an AWS IAM policy is changed. Add Slack into the mix, and you’ve got instant visibility for your DevOps or SecOps teams.

This blog will walk you through how to:

  • Detect AWS IAM policy changes using Amazon EventBridge and AWS CloudTrail.
  • Trigger the AWS Lambda function to format the event details.
  • Send these alerts directly to a Slack channel using a webhook.

The best part? You can set it up in minutes using the AWS CloudFormation (SAM) template.

Imagine a scenario where someone:

  • Adds AdministratorAccess to a user
  • Modifies a trusted role used by a CI/CD pipeline
  • Deletes an AWS IAM user with access keys

These events should trigger immediate attention, and that’s exactly what we’ll automate in this post using Slack notifications integrated with AWS Lambda, Amazon EventBridge, and AWS CloudTrail.

Reference: If you haven’t already set up a Slack bot for pushing messages, follow this guide to get started:
Post Messages to Slack Using AWS Lambda Function URLs

We will set up the following:

  • AWS CloudTrail to capture AWS IAM API activity
  • Amazon EventBridge Rule to filter relevant AWS IAM changes
  • AWS Lambda Function to format and send Slack messages
  • Slack Webhook Integration for real-time alerts

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

AWS CloudFormation Template

Here’s the CFT to deploy the AWS Lambda function, AWS IAM role, and Amazon EventBridge rule.

Python Lambda Function: iam_notify.py

Test It Out

  1. Deploy the stack with your Slack webhook SSM param already created.
  2. Perform an AWS IAM action such as:

3. Check your Slack channel, and the notification should arrive in seconds.

Why Monitor AWS IAM Policy Changes?

  • Security: Detect privilege escalation attempts in real-time.
  • Governance: Ensure only authorized CI/CD pipelines or users make changes.
  • Compliance: Maintain an audit trail for regulatory requirements.

Conclusion

Monitoring AWS IAM policy changes is non-negotiable for secure AWS operations. This solution enables instant visibility into such events, keeping your team informed and reactive. Best of all, it’s low-cost, serverless, and easily extendable.

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

Empowering organizations to become ‘data driven’ enterprises with our Cloud experts.

  • Reduced infrastructure costs
  • Timely data-driven decisions
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 850k+ professionals in 600+ cloud certifications and completed 500+ 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 CloudFront Service Delivery PartnerAmazon OpenSearch Service Delivery PartnerAWS DMS Service Delivery PartnerAWS Systems Manager Service Delivery PartnerAmazon RDS Service Delivery PartnerAWS CloudFormation Service Delivery PartnerAWS ConfigAmazon EMR and many more.

FAQs

1. What if I want to monitor more AWS IAM actions?

ANS: – You can expand the eventName list using the EventBridge rule. Include events like CreateUser, DeleteRole, UpdateGroup, etc.

2. How do I secure the Slack webhook URL?

ANS: – Store it in SSM Parameter Store as a SecureString, then fetch it in Lambda using the ${resolve:ssm:} syntax.

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!