How To Setup Slack To Receive Notifications From AWS Developer Tools?iam.awslagi
In this posts we will show you How To Setup Slack To Receive Notifications From AWS Developer Tools( AWS Codebuild, AWS Deploy, AWS CodePipeline, AWS Code Commit)
As announcements in yearly 2020 from AWS, now with only few clicks we able to setup slack to receive notifications from Developer Tools. This includes notifications such as CodeCommit source changes, completed CodeDeploy deployments, CodeBuild build completions and successful CodePipeline executions.
This new integration works with AWS Chatbot, an interactive agent that makes it easy to monitor and interact with your AWS resources.
In example we will create a notification is triggered when AWS Pipeline release change, success executions, succeeded and failed state.
We will configure AWS Chatbot to subscribe a SNS Topic.
To set up notifications, follow the following process, as shown in the following diagram:
1. Create a notification rule for AWS CodePipeline. This includes creating an Amazon SNS topic to use for notifications.
2. Configure AWS Chatbot to send notifications from that Amazon SNS topic to a Slack channel.
3. Validate results.
What Are Notifications?
The notifications feature in the Developer Tools console is a notifications manager for subscribing to events in AWS CodeBuild, AWS CodeCommit, AWS CodeDeploy and AWS CodePipeline. It has its own API, AWS CodeStar Notifications. You can use the notifications feature to quickly notify users about events in the repositories, build projects, deployment applications, and pipelines that are most important to their work. A notifications manager helps make users aware of events that occur on repositories, builds, deployments, or pipelines so that they can quickly take action, such as approving changes or correcting errors.
What Can I Do with Notifications?
You can use the notifications feature to create and manage notification rules to notify users of important changes to their resources, including:
- Build successes and failures in CodeBuild build projects.
- Deployment successes and failures in CodeDeploy applications.
- Creation of and updates in pull requests, including comments on code, in CodeCommit repositories.
- Manual approval statuses and pipeline runs in CodePipeline.
You can set up notifications so that they go to user email addresses that are subscribed to an Amazon SNS topic. You can also integrate this feature with AWS Chatbot and have notifications delivered to Slack channels or Amazon Chime chat rooms.
How Do Notifications Work?
When you configure a notification rule for a supported resource, such as a repository, build project, application, or pipeline, the notifications feature creates an Amazon EventBridge rule that monitors for the events you specify. When an event of that type occurs, the notification rule sends notifications to the Amazon SNS topics specified as targets for that rule. Subscribers to those targets receive notifications about those events.
If you haven’t had any pipeline you can following these steps in this link to create new one Create a Pipeline in CodePipeline or use an existing one.
Step 1: Create notifications for in CodePipeline
1. Select the pipeline in AWS CodePipeline.
2. Select pipeline for which you want to receive notifications. Choose Notify, then Create notification rule.
3. Provide notification name and information require. For Detail type I choose Basic.
- The Full setting (the default) includes all information available for the event in the notification, including any enhanced information provided by services for specific events.
- The Basic setting includes only a subset of the available information.
4. In Events, Select Succeeded in column Action execution and Pipeline execution.
5. In Targets, choose Create SNS topic. This automatically sets up a new Amazon SNS topic to use for notifications, applying a policy that allows notification events to be sent to it.
6. Finish creating the rule. Keep a note of the Amazon SNS ARN, as you need this information to configure Slack integration in the next step.
Step 2: Integrate your Amazon SNS topic with AWS Chatbot
1. Firstly, Open you slack channel.
2. Open AWS Chatbot console and choose configure client
3. Choose Configure new client, then Slack, then Configure.
4. AWS Chatbot asks for permission to access your Slack workplace, as seen in the following screenshot. Once you give permission, you are asked to configure your Slack channel.
Step 3: Configure Slack channel
1. Provide configuration name
2. Provide Slack channel
3. Create new IAM role for AWS Chatbot
4. Select SNS topics which you created in previous step.
Step 4: Validate
When you release Pipeline your slack channel will receive notifications like this:
Step 5: Clean up
To avoid any further charges you should delete all resources which you created.