Ends in
00
days
00
hrs
00
mins
00
secs
ENROLL NOW

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

Setting Up Slack Notifications for AWS Budget Alerts

Home » Others » Setting Up Slack Notifications for AWS Budget Alerts

Setting Up Slack Notifications for AWS Budget Alerts

Last updated on June 21, 2024

Introduction

Managing cloud costs effectively is crucial for businesses. AWS provides a feature to set budget alerts that notify you when your costs exceed a certain threshold. While these alerts can be sent via email, they can sometimes get lost in the flurry of daily emails, leading to delayed responses.

This is where real-time Slack notifications for AWS budget alerts come into play. By integrating AWS budget alerts with Slack, these notifications are sent directly to your Slack workspace. This ensures that the alerts are seen and acted upon in a timely manner, helping to prevent unexpected costs.

Setting Up Slack Notifications for AWS Budget Alerts

This blog post will guide you through the steps to set up Slack notifications for AWS budget alerts. This setup will allow you to receive notifications in your Slack workspace when your AWS costs exceed a certain threshold.

Implementation Steps:

Step 1: Login to your AWS Account.

Step 2: Create a Lambda Function

First, we need to create a Lambda function that will send the notifications to Slack. Here are the details for the function:

  • Function name: budget-alert-notifier
  • Runtime: Python 3.12
Tutorials dojo strip

Step 3: Lambda Function Code

Next, we need to add the code for our Lambda function. Here’s the Python code for the function. Feel free to modify this code based on your requirements.:

Step 4: Edit the General Configuration

In the General Configuration settings of your Lambda function, set the Timeout to 1 minute.

Setting Up Slack Notifications for AWS Budget Alerts

Step 5: Set Permissions

Under the Configuration of your Lambda function, go to the Permissions tab, then click on the existing execution role under the “Execution role” panel. This will take you to the IAM console, where you can add the necessary permissions by creating an inline policy. The permissions to add are GetCostAndUsage and SNSPublish.

GetCostAndUsage

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "ce:GetCostAndUsage",
            "Resource": "*"
        }
    ]
}

SNSPublish


{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "sns:Publish",
            "Resource": "*"
        }
    ]
}

  • GetCostAndUsage: This permission is required to allow the Lambda function to retrieve cost and usage data from AWS. The ce:GetCostAndUsage action allows the function to access the AWS Cost Explorer Service, which provides cost and usage data that is used to check if the costs exceed a certain limit.

  • SNSPublish: This permission is needed to allow the Lambda function to send messages to the Amazon SNS Topic. The sns:Publish action enables the function to publish the prepared message (the alert) to the specified Amazon SNS topic.

Step 6: Trigger the Lambda Function using Amazon SNS

Create an Amazon SNS Topic named budget-alert and modify the Access Policy.

Type: Standard

Setting Up Slack Notifications for AWS Budget Alerts

Click the Create Topic button at the bottom.

 

After that, copy the ARN of your SNS topic and modify the access policy. Refer to the JSON policy below.

Setting Up Slack Notifications for AWS Budget Alerts

 


{
  "Version": "2008-10-17",
  "Id": "__default_policy_ID",
  "Statement": [
    {
      "Sid": "__default_statement_ID",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": [
        "SNS:GetTopicAttributes",
        "SNS:SetTopicAttributes",
        "SNS:AddPermission",
        "SNS:RemovePermission",
        "SNS:DeleteTopic",
        "SNS:Subscribe",
        "SNS:ListSubscriptionsByTopic",
        "SNS:Publish",
        "SNS:Receive"
      ],
      "Resource": "your topic ARN",
      "Condition": {
        "StringEquals": {
          "AWS:SourceOwner": "<account-id>"
        }
      }
    },
    {
      "Sid": "Budget_Alert",
      "Effect": "Allow",
      "Principal": {
        "Service": "budgets.amazonaws.com"
      },
      "Action": "SNS:Publish",
      "Resource": "your topic ARN"
    }
  ]
}

Step 7: Add the SNS Topic to the Lambda Function

Go back to the AWS Lambda Function, and under Configuration, go to the Triggers tab and add the created SNS topic.

Setting Up Slack Notifications for AWS Budget Alerts

Step 8: Configure AWS Budgets

Go to AWS Budgets and configure the alerts.

Setting Up Slack Notifications for AWS Budget Alerts

Step 9: Add the Amazon SNS Alerts

Add the ARN of the created SNS topic to the Amazon SNS Alerts field. Once done, click next, then save the changes.

Setting Up Slack Notifications for AWS Budget Alerts

Setting Up Slack Notifications for AWS Budget Alerts

And that’s it! You’ve now set up real-time Slack notifications for AWS budget alerts. This setup not only helps in efficient cost management by keeping you informed about your AWS expenses in real-time but also leverages the convenience and immediacy of Slack, making it a valuable tool for any organization using AWS and Slack.

Get any AWS Specialty Mock Test for FREE when you Buy 2 AWS Pro-Level Practice Tests – as LOW as $10.49 USD each ONLY!

Tutorials Dojo portal

Learn AWS with our PlayCloud Hands-On Labs

Tutorials Dojo Exam Study Guide eBooks

tutorials dojo study guide eBook

FREE AWS Exam Readiness Digital Courses

Subscribe to our YouTube Channel

Tutorials Dojo YouTube Channel

FREE AWS, Azure, GCP Practice Test Samplers

Follow Us On Linkedin

Recent Posts

Written by: Nestor Mayagma Jr.

Nestor is a web developer and member of the AWS Community Builder. He continuously strives to expand his knowledge and expertise in AWS to foster personal and professional growth. He also shares his insights with the community through numerous AWS blogs, highlighting his commitment to Cloud Computing technology. In his leisure time, he indulges in playing FPS and other online games.

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?