Design, build, innovate & share cloud.

I've been talkn about AWS Budgets recently and would like to dive a little further into this neat service to integrate more services that are supported by AWS Budgets. Let's face it, emails are boring, we get tones of them, there is a lot of noise in the ops world it doesn't work too well. Let's explore adding a Chatbot to Budget to get notifications through third party chat services.

Screen-Shot-2020-10-17-at-8.48.37-pm

If you haven't already checked out my previous post on AWS Budgets, getting setting up and using the AWS CDK + CloudFormation Deploy Stack. Swing by my previous post as this will continue on from that with the addition of AWS Chatbot.

Outputs

I have selected Slack for this demo for no other reason other than it's a popular service and supported by Chatbot. You probably know what it's about by now and it's common to see out there in ops land. If you don't know, it's a messaging platform, there is a desktop and mobile client, channels, conversations etc. I'm going to assume you've already signed up for Slack and know how to get around, it's not too hard if don't so don't be alarmed.

Let's dive right in

OK, now there will be some console action in this. We need to authorize Slack and AWS Chatbot using the AWS Console.

Chatbot configuration

  1. Jump into the AWS Console
  2. Head over to AWS Chatbot
    3. You'll see the welcome screen, we'll add a new Slack client right off the welcome screen.

Screen-Shot-2020-10-15-at-8.12.45-pm

Screen-Shot-2020-10-17-at-2.02.28-pm

  1. If you're already logged in and have permission in Slack you'll be greeted with the configuration screen to permit AWS Chatbot app to connect with Slack.

Screen-Shot-2020-10-15-at-8.16.08-pm

  1. Review the permissions and hit allow
  2. Now you'll have a Workspace ID that we can use

Screen-Shot-2020-10-17-at-2.03.10-pm

Note: Notice we don't have any other configuration, that will come later

Slack configuration

  1. Open up your Slack space so you can see your channels
  2. If you don't have a channel, create a new one
  3. Add the AWS app to the channel (add apps button to the left), you see AWS because we authorized it in the console

Screen-Shot-2020-10-17-at-2.18.17-pm

  1. Now we need the channel ID, the easiest way is to click on the channel and then look in the top bar with the URL is. The very end ID is the Channel ID. E.g. X10XXX1XXXX
    5. You can also right click the channel and go copy link, again is the last portion of the link after the "/"

AWS CloudFormation Deploy Stack - IaC, Yay!

Like my previous post, I have supplied a CF Deploy Stack Button, simple click the button below and this will configure AWS Budgets, AWS SNS, AWS Chatbots etc for you in a neat tidy stack.

As above, here are the parameters:

  • Email
    • Where do you want to receive email notifications for billing alarms
  • Slack Channel ID
  • Slack Workspace ID
  • Spend (Budget)
    • This is in USD, the alarm threshold is 80% of this value

Launch Stack

Screen-Shot-2020-10-17-at-8.38.47-pm

Once deployed you can head back to Slack and type @aws in your ChatOps channel and you should receive some help back.

Screen-Shot-2020-10-17-at-2.22.08-pm

AWS CDK

If you're into AWS CDK the whole project is available on Github so you can synth and deploy the stack. This way you can remove some of the parameters and custom as needed.

cdk deploy --parameters email=demo@example.com --parameters spend=10 --parameters workspace=XXXXMICKXXXX --parameters channel=XXXXTALKNCLOUDXXXX

The code the CDK stack (also used for the CF deploy) is, as always, open source and up on Github:

talkncloud/aws
all things cloud from IaC to full apps. Contribute to talkncloud/aws development by creating an account on GitHub.

But what does it all mean?

OK, so if you're here you might be wondering what I'll end up with. This project is different from the previous where the budget was based on actual spend e.g. money spent, I have configured this one to use forecasted amounts so that you can try and get ahead of the budget. Once the forecast passes 80% of your set budget, the alarms begin!

Note: forecasted can take a little while for AWS to return

AWS Chatbot configured

If you have a look into the Chatbot console you can see the newly applied configuration:

Screen-Shot-2020-10-17-at-7.28.31-pm

AWS Budget hooked up to SNS and Email

If you check out Budgets you can see your budget has been set and notifications are wired up to the SNS topic:

Screen-Shot-2020-10-17-at-7.30.24-pm

AWS Budget hitting the threshold

Here is a example of AWS Budget hitting the budget threshold:

Screen-Shot-2020-10-17-at-2.27.15-pm

AWS Budget alarm in email

Not too exciting, but useful none the less:

Screen-Shot-2020-10-17-at-12.43.43-pm

AWS Budget alarm in Slack!!!!

And now you should receive an alarm is Slack, very cool!

Screen-Shot-2020-10-17-at-12.43.29-pm

Clean up (yargah!)

Because we had to setup the authorization between AWS Chatbot and Slack manually it should go without saying you'll need to remove that manually if you destroy / remove the stack.

If anyone is aware of a way to script this part in the stack I'd be keen to know, as I've seen a couple of other services like this pop in AWS.

This is free???

It's always good to look over the service FAQ's and pricing before you plan on using AWS services:

In short, yes, this won't cost a dime, you'll get two Budgets for free before you start pay a little (cents). Chatbot is actually free, no limits you pay for the underlying services. SNS free tier allows for millions of messages which isn't likely in Budget notifications.

Final thoughts

I really wanted to highlight how neat the AWS Chatbot service, it's a free service and really offers a more modern experience over emails. It would be good if there were more services available as at the moment it is limited to AWS Chime and Slack, I am sure they'll come along soon enough. If you like AWS Chatbot be sure to have a play, what I have left out is that you can actually trigger other services like Lambda from Slack to do something in your AWS environment! Be creative!

Again, if you know how to script the authentication part of Slack and AWS Chatbot please reach out.

You've successfully subscribed to talkncloud
Welcome back! You've successfully signed in.
Great! You've successfully signed up.
Success! Your account is fully activated, you now have access to all content.