Let’s Slack with AWS Chatbot

Pamela Tung
4 min readMay 11, 2020

CI/CD pipeline (AWS CodeCommit, CodeBuild, etc)

Photo by Christian Bowen on Unsplash

In April 2020, AWS launched a new bot into the world. AWS Chatbot is now generally available for everyone!

AWS Chatbot is an interactive agent robot for “ChatOps”. It can be used to send notifications to monitor and provide alerting with regards to your AWS resources. AWS Chatbot can integrate with Slack and Amazon Chime (AWS’s latest video conference and online meeting service).

Best of all, AWS Chatbot itself is absolutely free of charge ($0) as of the time of writing this article. That makes AWS Chatbot a very cool and friendly bot! Hence, the picture of the cool ice cream and the friendly dog above, in case you’re wondering. :)

AWS Chatbot can be used in multiple different scenarios. For today’s knowledge-sharing, I am excited to share with you how to integrate AWS CodeBuild with AWS Chatbot so that if your automated builds succeed or fail as part of your CI/CD pipeline, you would get a nice Slack notification in your Slack channel.

Automated builds’ success or failure will notify a Slack channel via AWS Chatbot

Just 3 easy steps. Let’s start!

Step 1: Add the AWS app to Slack and configure a channel

From Slack, click on the + sign to browse for an App.

Search for: AWS Chatbot, and click on the Add button to launch the page, and then the green button “Add to Slack”.

Next, create a new Slack channel if you would like the new channel to receive the notifications. In this example, I have named the new channel #aws-codebuild.

Create a new Slack channel if you would like the new channel to receive the CodeBuild notifications

Step 2: Create your bot and give it the right security permissions

From the AWS Management Console, navigate to the AWS Chatbot service. Select Slack as your client, and Configure client.

If you have more than one Slack workspace, when you come to this page, do select the right workspace that you have created the channel in. In the top right corner, you can select and login to the workspace if you wanted to switch to a different one.

Click the green Allow button.

Next, configure your new channel by selecting the orange button Configure new channel.

Name the new configuration eg. my-awesome-configuration. Select the name of the new Slack channel that you had previously created eg. aws-codebuild.

Now to ensure the Chatbot has the important security permissions. Ensure the IAM role has the policy template “Notification permissions” which will give you the policy AWS-ChatBot-NotificationsOnly-Policy. This is the default policy template which is already selected as the picture below shows. So you do not have to do anything special, other than to input a nice name for the Role eg. AWSChatbot-role.

Select Create an IAM role using a template, and then give the Role a nice name eg. AWSChatbot-role

Finally, when everything looks beautiful, click “Configure”. If all things have been done right, you would see a green message. The last sentence there is an action item for you moving into the next and final Step 3.

You have successfully configured the Slack channel from inside of AWS Chatbot

Step 3: Ask Slack to invite AWS Chatbot, and then let’s build and test

Go into the Slack channel eg. aws-codebuild and invite AWS Chatbot by executing the /invite @aws command.

/invite @aws

In AWS Management Console, navigate to CodeBuild, under Settings, Notifications tab, create a new Notification rule.

Input your notification name eg. myCoolRobotSlack

Select the Build states to track in the Slack channel. You may select all of them if you like.

Select AWS Chatbot (Slack) as the target, and choose the configuration that you have just done eg. my-awesome-configuration. Click Submit. And we’re DONE!

Now let’s test. Go to your project and Start Build.

When the build completes, go to the Slack channel and you will see this beautiful message!

Slacks from a happy bot! :)

Summary

This knowledge sharing shows you how to integrate AWS CodeBuild with AWS Chatbot to receive Slack notifications which is really nice because the team can be notified when code fails (or passes) build and test. You can do the same with AWS CodeCommit for example, receive Slack notifications when Developers check in code or pull requests. And with AWS CodeDeploy to receive notifications based on the status of deployments. That way, chaining with the rest of the AWS CodePipeline services, you can now slack with your very own cool and friendly bot!

--

--

Pamela Tung

love to encourage the young at heart on their Agile adventures.