DEV Community

Cover image for AWS Chatbot and AWS Budget with Slack, CDK + CF
Mick Jacobsson
Mick Jacobsson

Posted on

AWS Chatbot and AWS Budget with Slack, CDK + CF

I recently wrote an article about AWS Budget and supplied a Github repo with CloudFormation to get up and running with Budgets nice and quick. But, the notifications for the budget alarms went via email which is kinda boring. This article builds on that to use AWS Chatbot to integrate with Slack to get notifications.

Full article for previous write up at https://www.talkncloud.com/aws-essential-setting-budget-and-alarms/

There are three key parts to this setup:

1. Setup a Slack channel
2. Setup AWS Chatbot and authenticate with Slack
3. Deploy the stack via the Deploy Stack button or AWS CDK
Enter fullscreen mode Exit fullscreen mode

Slack Channel

Create a new Slack channel and grab the channel ID, you'll find the channel ID at the end of the url if you're in the channel after the last "/"

AWS Chatbot

Login to the AWS console and head over to Chatbot. The welcome screen will ask you to configure a client, go ahead and configure a new slack client. If you're already authenticated you'll be presented with a permissions overview and request to "Allow" the proposed. Review and proceed.

When you return you should land on the chatbot screen, grab the workspace ID, we'll need it later.

Slack App

Jump back into Slack and add the AWS app to your Slack channel, I setup a demo aws-chatops channel for this demo but you might have an existing chatops channel to use. It should appear in your apps and won't need to be authenticated from here.

Deploy the stack

I've provided a "Deploy Stack" CloudFormation project ready to go. Head over to the Github repo page and hit the button. You'll need to enter the following parameters into AWS CloudFormation after hitting the button:

1. Email
2. Workspace ID
3. Slack Channel ID
4. Spend / Budget
Enter fullscreen mode Exit fullscreen mode

Like the previous project, everything is available and open source. Please feel free to share, make edits, improve etc. I should also note the stack is written in AWS CDK, so you can totally customize it, remove the parameters and is a working example of Budget, SNS and Chatbot.

https://github.com/talkncloud/aws/tree/main/essential-billing-bot

The end result

You'll end up with a pretty sweet setup, once your budget hits 80% you'll receive an email and also a notification in your slack channel which should flow nicely into any existing chatops workflows you have already.

More details

If you want to get into more details I have a detailed write up on this setup and it outlines the costs associated with this deployment. You can check out the full write up on talkncloud - https://www.talkncloud.com/enter-the-bots-aws-budgets-with-bots/

If you have any questions please let me know, happy to help out!

Top comments (0)