<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joseph Ntwali on Medium]]></title>
        <description><![CDATA[Stories by Joseph Ntwali on Medium]]></description>
        <link>https://medium.com/@ntwarijoseph2050?source=rss-1eb020f01b89------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UkpwLVzx_m1vyGYhkCdwkA.jpeg</url>
            <title>Stories by Joseph Ntwali on Medium</title>
            <link>https://medium.com/@ntwarijoseph2050?source=rss-1eb020f01b89------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:49:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ntwarijoseph2050/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Set Up AWS Billing Alerts to Slack]]></title>
            <link>https://medium.com/@ntwarijoseph2050/set-up-aws-billing-alerts-to-slack-in-10-minutes-27db66c08d0a?source=rss-1eb020f01b89------2</link>
            <guid isPermaLink="false">https://medium.com/p/27db66c08d0a</guid>
            <dc:creator><![CDATA[Joseph Ntwali]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 14:52:40 GMT</pubDate>
            <atom:updated>2025-08-22T15:39:31.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mXELgrrkEU0iOAmU6psFSg.jpeg" /></figure><p>Most developers, startups and cloud engineers in their daily life they use to receive unexpectedly AWS bills which may cause them to be frustrated sometimes.</p><p>In this documentation, i am going to show how we can setup automated monitoring strategy of receiving real-time Slack alerts in your channel, whenever your limits you have set is reached.</p><p><strong>🛠️1. Tools Used</strong></p><p>To build this solution, we are going to use the combination of AWS resources and Slack features which includes:</p><ul><li><strong>AWS CloudWatch</strong> — to create billing alarms based on estimated charges.</li><li><strong>Amazon SNS (Simple Notification Service)</strong> — to deliver alarm notifications.</li><li><strong>AWS Lambda</strong> — to format and forward the alerts to Slack.</li><li><strong>Slack Webhooks</strong> — to receive the alerts inside a Slack channel.</li></ul><p><strong>🧩 2. Prerequisites</strong></p><p>In order to implement this process of sending AWS Billing alerts to Slack we must have in place the:</p><ul><li>AWS Account</li><li>Slack Workspace</li><li>Basic familiarity with the AWS Console</li></ul><p>once all the above requirements are made then we are going to begin the actual implementation.</p><h3>🔔 Step 1: Create a CloudWatch Billing Alarm</h3><p>In this step we will setup the billing alarm that must trigger when our monthly charges exceeds certain threshold that we are going to set.</p><h4>1. Go to the AWS Billing Console</h4><ul><li>Navigate to the <strong>AWS Billing Dashboard</strong>.</li><li>In the left sidebar, click on <strong>Budgets</strong>, then click <strong>“Create budget”</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eQX_2onXsR-eglTnqQea3w.png" /></figure><h4>2. Choose Budget Type</h4><ul><li>Select <strong>Cost budget</strong>, then click <strong>Next.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlevBSgWDGxXW1uyq-A6pQ.png" /></figure><h4>3. Set Budget Details</h4><ul><li><strong>Name</strong> your budget (e.g. MonthlyCostBudget).</li><li>Set a threshold (e.g. $5.00).</li><li>Choose Recurring as the budget type and select your time period (Monthly).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxJ_PYQNprtyc4LatykzEg.png" /></figure><h4>4. Configure Alerts</h4><ul><li>Under <strong>Alerts</strong>, enable notifications when actual costs exceed your threshold.</li><li>Click <strong>Add an alert threshold</strong>, then enter a threshold like <strong>100%</strong>.</li><li>For the <strong>Alert recipient</strong>, choose <strong>Amazon SNS topic</strong>.</li></ul><blockquote><em>⚠️ If you don’t have an SNS topic yet, you can create a new one here or later.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4FFD3FVLWIUa3K669B1MpA.png" /></figure><h4>5. Review and Create</h4><ul><li>Review your settings and click <strong>Create budget</strong>.</li></ul><p>✅ Done! You now have a billing alarm set up.</p><h3>📣 Step 2: Create an SNS Topic</h3><p>In order to notify slack and trigger Lambda function when our billing alarms reaches, we need to setup the AWS SNS (Simple Notification Service) topic. (SNS Topic).</p><h4>1. Go to Amazon SNS in the AWS Console</h4><ul><li>Navigate to the <strong>Amazon SNS Dashboard</strong>.</li><li>In the sidebar, click on <strong>Topics</strong> &gt; <strong>Create topic</strong>.</li></ul><h4>2. Create a New Topic</h4><ul><li><strong>Type</strong>: Select <strong>Standard</strong>.</li><li><strong>Name</strong> your topic aws-billing-alerts.</li><li>Leave other settings as default, then click <strong>Create topic</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qWQsxgHrqo33K1_VE_Tt-Q.png" /></figure><p>Now lets create a new <strong>Slack WebHook URL</strong></p><p><strong>Step 1: Go to Slack App Integrations</strong></p><ul><li>Visit: <a href="https://api.slack.com/apps">https://api.slack.com/apps</a></li><li>Click <strong>“Create New App”</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKbYfrEcQM5HFA_Sj9BmIw.png" /></figure><p>after click the Create New App, then proceed with <strong>From scratch</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWaiLCp--ps7P9GxkBOaaw.png" /></figure><p>Then specify the App Name and select the workspace you want to receive your alerts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0ibLBNOZoFWpAsfgGFnWyQ.png" /></figure><p><strong>Step 3: Enable Incoming Webhooks</strong></p><ul><li>In the left sidebar, click <strong>“Incoming Webhooks”</strong></li><li>Toggle <strong>“Activate Incoming Webhooks”</strong> to <strong>ON</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kxd7Zhh7vpKC9ffq9aRnjg.png" /></figure><p><strong>Step 4: Add a New Webhook to a Channel</strong></p><ul><li>Scroll down and click <strong>“Add New Webhook to Workspace”</strong></li><li>Choose the channel where you want to receive billing alerts (e.g. #cloud-alerts)</li><li>Click <strong>Allow</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bRTO39qFupswLeggAAcN2w.png" /></figure><p><strong>Step 5: Copy Your Webhook URL</strong></p><ul><li>After authorization, you’ll see a webhook URL like:</li><li><a href="https://hooks.slack.com/services/TXXXXX/BXXXXX/XXXXXXXX">https://hooks.slack.com/services/TXXXXX/BXXXXX/XXXXXXXX</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZ_-jHIiEigEkcI5R9-EOw.png" /></figure><p>Copy this URL — you’ll paste it into the SNS subscription in the next step.</p><h4>3. Add a Slack Webhook Subscription</h4><ul><li>After creating the topic, click <strong>Create subscription</strong>.</li><li><strong>Protocol</strong>: Choose HTTPS.</li><li><strong>Endpoint</strong>: Paste your <strong>Slack Webhook URL </strong>we got from the WebHook.</li></ul><h4>📣 Step 4: How to Create a Lambda Function to Process SNS Messages</h4><h4>Step 1: Go to AWS Lambda Console</h4><ul><li>Navigate to: <a href="https://console.aws.amazon.com/lambda">https://console.aws.amazon.com/lambda</a></li><li>Click <strong>“Create function”</strong></li></ul><h4>Step 2: Configure the Function</h4><ul><li><strong>Function name</strong>: ProcessBillingAlertToSlack</li><li><strong>Runtime</strong>: Python 3.12 (or Node.js, depending on your preference — we’ll use Python here)</li><li>Click <strong>“Create function”</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ihhH7rrE8oJNazniKzqFg.png" /></figure><h4>Step 3: Add the Lambda Code</h4><p>Scroll down to the <strong>“Function code”</strong> section and replace the default code with the following Python snippet: remember</p><pre>import json<br>import urllib3<br><br>http = urllib3.PoolManager()<br><br>SLACK_WEBHOOK_URL = &quot;https://hooks.slack.com/services/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&quot;<br><br>def lambda_handler(event, context):<br>    try:<br>        # Get the billing alert message from SNS<br>        message = event[&#39;Records&#39;][0][&#39;Sns&#39;][&#39;Message&#39;]<br>        <br>        # Format message for Slack<br>        slack_data = {<br>            &quot;text&quot;: f&quot;💰 *AWS Billing Alert*\n{message}&quot;<br>        }<br><br>        # Send message to Slack<br>        encoded_data = json.dumps(slack_data).encode(&#39;utf-8&#39;)<br>        response = http.request(<br>            &#39;POST&#39;,<br>            SLACK_WEBHOOK_URL,<br>            body=encoded_data,<br>            headers={&#39;Content-Type&#39;: &#39;application/json&#39;}<br>        )<br><br>        if response.status != 200:<br>            print(f&quot;Slack webhook failed: {response.status}&quot;)<br>            return {<br>                &#39;statusCode&#39;: response.status,<br>                &#39;body&#39;: &#39;Failed to send message to Slack.&#39;<br>            }<br><br>        return {<br>            &#39;statusCode&#39;: 200,<br>            &#39;body&#39;: &#39;Message sent to Slack.&#39;<br>        }<br><br>    except Exception as e:<br>        print(f&quot;Error: {e}&quot;)<br>        return {<br>            &#39;statusCode&#39;: 500,<br>            &#39;body&#39;: str(e)<br>        }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yaNPbbDJdmVhiZn5bCtWFQ.png" /></figure><p>✅ <strong>“N.B”</strong>Replace the webhook_url with your actual Slack webhook URL.</p><h4>📣 Step 5: Add the Lambda Function as an SNS Subscription</h4><p>Now we are going to create new Subscription which will have the previous Topic we have created and also for the Protocal this time we should use Lambda and choose the Endpoint that we have created from the Lambda section part and click <strong>CREATE SUBSCRIPTION</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09BKdngpE_VMyhmGDT_eNg.png" /></figure><h3>✅ Done!</h3><p>Now, when the billing alarm is triggered, SNS will send the alert message to your Lambda function — and it will post a clean, structured notification to your Slack channel that should look like the below one i have received during testing.</p><p>💬 <strong>Got questions or feedback?</strong><br> Feel free to connect with me on social media — especially <a href="https://www.linkedin.com/in/ngabonziza-ntwali-joseph-544a2618b/">LinkedIn</a> — or reach out via <a href="http://ntwarijoseph2050@gmail.com/">email</a>. I’m always happy to connect, collaborate, or help where I can!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27db66c08d0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>