Seamless Monitoring: Get Slack Alerts for Every AWS Lambda Function Update

Home » AWS » Seamless Monitoring: Get Slack Alerts for Every AWS Lambda Function Update

Seamless Monitoring: Get Slack Alerts for Every AWS Lambda Function Update

Keeping track of updates in your AWS Lambda function seems like an easy task, but it is actually time-consuming. Leaving your Lambda function unattended after deployment may incur risks in missing crucial updates that may affect its overall performance and functionality. And most of the time, you also do development tasks which might limit your attention to these Lambda functions. That’s why you must be informed whenever an update is made to your Lambda function. Whether done by yourself or by your teammates and collaborators, being informed of these changes will help you maintain its efficiency, especially when diagnosing issues that may arise. Provided in this article is an easy solution to automate Lambda function update notifications through Slack. This will help you set up real-time alerts to ensure every modification in your function is visible to you and your team.

Step-by-step Guide

1. Create the Lambda function that will send notifications to Slack

Set the following configurations:

  • Function name: SlackNotifLambdaUpdate (feel free to change this)
  • Runtime: Python 3.13

Here’s the code that will be used to send notifications to Slack. Feel free to modify it based on your own preference

Tutorials dojo strip

2. Create an EventBridge rule to detect update on Lambda function

  • Go to Amazon EventBridge -> Rules.
  • Click Create rule and enter a name (e.g., MonitorLambdaCodeChanges).
  • Under Define pattern, select Event pattern and use the Custom pattern option.
  • Copy and paste the following event pattern below:
  •  
{
  "source": ["aws.lambda"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventSource": ["lambda.amazonaws.com"],
    "eventName": ["UpdateFunctionCode"],
    "requestParameters": {
      "functionName": ["ARN of Lambda function to be monitored"]
    }
  }
}
  • Add a target then select the Lambda function created above.

3. Set the following configurations for the Lambda function

  • Add the following environmental variable:
    • SLACK_WEBHOOK_URL – <your-slack-webhook-URL>
  • Add ‘requests’ layer
    • Make sure you downloaded first the requests layer from your local library
  • Add permission to invoke EventBridge rule
    • Service: EventBridge (CloudWatch Events)
    • Statement ID: invoke-eventbridgerule
    • Principal: events.amazonaws.com
    • Source ARN: <ARN of created EventBridge rule>
    • Action: lambda:InvokeFunction
    • Click Save

Expected Output:

After completing the steps above, let’s test if Slack sends a notification whenever we update the monitored Lambda function.Slack notification lambda function updateGood job! Since Slack sends a notification displaying the Lambda function name and the user who edited it, you and your team will always stay informed about any changes and who made them. This will help identify potential issues and improve its reliability. With the proper integration of these AWS services and Slack, monitoring your deployed projects is now easier to achieve, giving you time to focus on more important tasks. 

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

FREE AWS Exam Readiness Digital Courses

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS, Azure, GCP Practice Test Samplers

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

Follow Us On Linkedin

Recent Posts

Written by: Lois Dar Juan

Lois is a fresh graduate of BS ECE and current Junior Cloud Engineer of Tutorials Dojo. Motivated by his interest in engineering, Lois is keen on expanding his expertise and competency in cloud computing and the broader IT industry.

AWS, Azure, and GCP Certifications are consistently among the top-paying IT certifications in the world, considering that most companies have now shifted to the cloud. Earn over $150,000 per year with an AWS, Azure, or GCP certification!

Follow us on LinkedIn, YouTube, Facebook, or join our Slack study group. More importantly, answer as many practice exams as you can to help increase your chances of passing your certification exams on your first try!

View Our AWS, Azure, and GCP Exam Reviewers Check out our FREE courses

Our Community

~98%
passing rate
Around 95-98% of our students pass the AWS Certification exams after training with our courses.
200k+
students
Over 200k enrollees choose Tutorials Dojo in preparing for their AWS Certification exams.
~4.8
ratings
Our courses are highly rated by our enrollees from all over the world.

What our students say about us?