Set Up AWS CodeCommit Pull Request Notifications for Slack Channel | AWS Chatbot Client

How to Create CodeCommit Pull Request Notifications for Slack Channel using AWS Chatbot Client

Prev Question Next Question

Question

An AWS Chatbot client is configured in your AWS account that can send notifications to the Slack workspace of your team.

The team starts to manage Git repositories in AWS CodeCommit.

In order to monitor important changes of source code, you need to set up a rule to notify users whenever a pull request is created and merged in the repositories.

The notifications should be sent to the Slack channel through the AWS Chatbot client.

How would you create the notification?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer : B.

Option A is incorrect because in a notification rule, there are two target types: SNS topic and AWS Chatbot (Slack)

In this scenario, AWS Chatbot (Slack) should be selected:

Option B is CORRECT because you can create a notification rule in a CodeCommit repository and select the events that trigger notifications:

Then you can register the AWS Chatbot client as the target.

Option C is incorrect because you cannot set up the CodeCommit notification rule through the AWS Chatbot client.

The rule needs to be configured in the AWS CodeCommit console.

Option D is incorrect because this is not how a notification rule is created in CodeCommit.

You do not need to create a new SNS topic for this.

Reference:

https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-repository-email.html, https://docs.aws.amazon.com/codecommit/latest/userguide/notification-rule-create.html
Targets

Create a target to use specifically for this notification rule. SNS topics created as targets have no subscribers but have
all policies applied to act as a target for notifications. If you choose AWS Chatbot, you will be redirected to create a
client in the AWS Chatbot console. Learn more [4

Create target

Configured targets

Choose target type Choose target
SNS topic | [a
SNS topic

AWS Chatbot (Slack)

The correct answer for this question is A. Create a notification rule in the CodeCommit repository, select the pull request events, choose “SNS topic” in the target type and input the SNS topic ARN of the AWS Chatbot client.

To set up notifications for pull request events in AWS CodeCommit repositories and send them to a Slack channel through an AWS Chatbot client, you need to follow these steps:

  1. Create an AWS Chatbot client: First, you need to create an AWS Chatbot client in your AWS account and configure it to send notifications to your Slack workspace. To do this, you can follow the steps provided in the AWS Chatbot documentation.

  2. Create an SNS topic: Next, you need to create an SNS topic in your AWS account. An SNS topic is a logical access point that allows you to publish messages to multiple subscribers. In this case, the SNS topic will be used to publish notifications about pull request events in your CodeCommit repositories.

  3. Subscribe the AWS Chatbot client ID to the SNS topic: After creating the SNS topic, you need to subscribe the AWS Chatbot client ID to the topic. This will allow the Chatbot client to receive notifications whenever a new message is published to the topic.

  4. Create a notification rule in the CodeCommit repository: Now that you have set up the AWS Chatbot client and the SNS topic, you can create a notification rule in your CodeCommit repository. To do this, go to the CodeCommit console and select the repository you want to set up notifications for. Then, click on the "Settings" tab and choose "Notification rules". Click on "Create rule" and select "Pull request created" and "Pull request merged" as the events that trigger the notification.

  5. Choose “SNS topic” in the target type: After selecting the events, choose "SNS topic" in the target type drop-down menu. Then, enter the ARN of the SNS topic you created in step 2.

  6. Customize the notification information: Optionally, you can customize the information that will be included in the notification message. You can include details such as the repository name, pull request title, and author.

  7. Save the notification rule: Once you have set up the notification rule, click "Create" to save it. Now, whenever a pull request is created or merged in the repository, a notification will be sent to the Slack channel through the AWS Chatbot client.