

# Configuring notifications for events in an AWS CodeCommit repository
Configuring notifications for repository events

You can set up notification rules for a repository so that repository users receive emails about the repository event types you specify. Notifications are sent when events match the notification rule settings. You can create an Amazon SNS topic to use for notifications or use an existing one in your Amazon Web Services account. You can use the CodeCommit console and the AWS CLI to configure notification rules.

![\[A notification rule configured in an CodeCommit repository\]](http://docs.aws.amazon.com/codecommit/latest/userguide/images/create-notification-rule-repository.png)


**Topics**
+ [

## Using repository notification rules
](#how-to-repository-email-using)
+ [

# Create a notification rule
](notification-rule-create.md)
+ [

# Change or disable notifications
](how-to-repository-email-console-edit.md)
+ [

# Delete notifications
](how-to-repository-email-delete.md)

## Using repository notification rules


Configuring notification rules helps your repository users by sending emails when someone takes an action that affects another user. For example, you can configure a notification rule to send notifications when comments are made on commits. In this configuration, when a repository user comments on a line of code in a commit, other repository users receive an email. They can sign in and view the comment. Responses to comments also generate emails, so repository users stay informed.

Notification rules are different from repository triggers, and they are also different than the notifications you could configure in the CodeCommit console before November 5, 2019. 
+ Although you can configure a trigger to use Amazon SNS to send emails about some repository events, those events are limited to operational events, such as creating branches and pushing code to a branch. Triggers do not use CloudWatch Events rules to evaluate repository events. They are more limited in scope. For more information about using triggers, see [Manage triggers for a repository](how-to-notify.md).
+ Notifications configured before November 5, 2019 had fewer event types available, and could not be configured for integration with Amazon Chime chatrooms or Slack channels. You can continue to use notifications configured before November 5, 2019, but you cannot create notifications of this type. Instead, create and use notification rules. We recommend using notification rules and disabling or deleting notifications created before November 5, 2019. For more information, see [Create a notification rule](notification-rule-create.md) and [Delete notifications](how-to-repository-email-delete.md). 

# Create a notification rule


You can use notification rules to notify users of important changes, such as when a pull request is created in a repository. Notification rules specify both the events and the Amazon SNS topic that is used to send notifications. For more information, see [What are notifications?](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/welcome.html)



**Note**  
This feature is not available in the Europe (Milan) Region. To learn how to configure notifications in the experience available in that Region, see [Configure Repository Notifications](https://github.com/awsdocs/aws-codecommit-user-guide/blob/master/doc_source/how-to-repository-email-create.2.md).

You can use the console or the AWS CLI to create notification rules for AWS CodeCommit. <a name="notification-rule-create-console"></a>

# To create a notification rule (console)


1. Sign in to the AWS Management Console and open the CodeCommit console at [https://console.aws.amazon.com/codecommit/](https://console.aws.amazon.com/codecommit/).

1. Choose **Repositories**, and then choose a repository where you want to add notification rules.

1. On the repository page, choose **Notify**, and then choose **Create notification rule**. You can also go to the **Settings** page for the repository and choose **Create notification rule**.

1. In **Notification name**, enter a name for the rule.

1. In **Detail type**, choose **Basic** if you want only the information provided to Amazon EventBridge included in the notification. Choose **Full** if you want to include information provided to Amazon EventBridge and information that might be supplied by the CodeCommit or the notification manager.

   For more information, see [Understanding Notification Contents and Security](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/security.html#security-notifications).

1.  In **Events that trigger notifications**, select the events for which you want to send notifications. For more information, see [ Events for Notification Rules on Repositories](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/concepts.html#events-ref-repositories).

1. In **Targets**, do one of the following:
   + If you have already configured a resource to use with notifications, in **Choose target type**, choose either **Amazon Q Developer in chat applications (Slack)** or **SNS topic**. In **Choose target**, choose the name of the client (for a Slack client configured in Amazon Q Developer in chat applications) or the Amazon Resource Name (ARN) of the Amazon SNS topic (for Amazon SNS topics already configured with the policy required for notifications).
   + If you have not configured a resource to use with notifications, choose **Create target**, and then choose **SNS topic**. Provide a name for the topic after **codestar-notifications-**, and then choose **Create**.
**Note**  
If you create the Amazon SNS topic as part of creating the notification rule, the policy that allows the notifications feature to publish events to the topic is applied for you. Using a topic created for notification rules helps ensure that you subscribe only those users that you want to receive notifications about this resource.
You cannot create an Amazon Q Developer in chat applications client as part of creating a notification rule. If you choose Amazon Q Developer in chat applications (Slack), you will see a button directing you to configure a client in Amazon Q Developer in chat applications. Choosing that option opens the Amazon Q Developer in chat applications console. For more information, see [ Configure Integrations Between Notifications and Amazon Q Developer in chat applications](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/notifications-chatbot.html).
If you want to use an existing Amazon SNS topic as a target, you must add the required policy for AWS CodeStar Notifications in addition to any other policies that might exist for that topic. For more information, see [Configure Amazon SNS Topics for Notifications ](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/set-up-sns.html) and [Understanding Notification Contents and Security](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/security.html#security-notifications). 

1. To finish creating the rule, choose **Submit**.

1. You must subscribe users to the Amazon SNS topic for the rule before they can receive notifications. For more information, see [Subscribe Users to Amazon SNS Topics That Are Targets](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/subscribe-users-sns.html). You can also set up integration between notifications and Amazon Q Developer in chat applications to send notifications to Amazon Chime chatrooms. For more information, see [Configure Integration Between Notifications and Amazon Q Developer in chat applications](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/notifications-chatbot.html).<a name="notification-rule-create-cli"></a>

# To create a notification rule (AWS CLI)


1. At a terminal or command prompt, run the **create-notification rule** command to generate the JSON skeleton:

   ```
   aws codestar-notifications create-notification-rule --generate-cli-skeleton > rule.json
   ```

   You can name the file anything you want. In this example, the file is named *rule.json*.

1. Open the JSON file in a plain-text editor and edit it to include the resource, event types, and target you want for the rule. The following example shows a notification rule named **MyNotificationRule** for a repository named *MyDemoRepo* in an AWS acccount with the ID *123456789012*. Notifications with the full detail type are sent to an Amazon SNS topic named *MyNotificationTopic* when branches and tags are created:

   ```
   {
       "Name": "MyNotificationRule",
       "EventTypeIds": [
           "codecommit-repository-branches-and-tags-created"
       ],
       "Resource": "arn:aws:codecommit:us-east-1:123456789012:MyDemoRepo",
       "Targets": [
           {
               "TargetType": "SNS",
               "TargetAddress": "arn:aws:sns:us-east-1:123456789012:MyNotificationTopic"
           }
       ],
       "Status": "ENABLED",
       "DetailType": "FULL"
   }
   ```

   Save the file.

1. Using the file you just edited, at the terminal or command line, run the **create-notification-rule** command again to create the notification rule:

   ```
   aws codestar-notifications create-notification-rule --cli-input-json  file://rule.json
   ```

1. If successful, the command returns the ARN of the notification rule, similar to the following:

   ```
   {
       "Arn": "arn:aws:codestar-notifications:us-east-1:123456789012:notificationrule/dc82df7a-EXAMPLE"
   }
   ```

# Change or disable notifications


You can use the AWS CodeCommit console to change how notifications created before November 5, 2019 are configured, including the event types that send emails to users and the Amazon SNS topic used to send emails about the repository. You can also use the CodeCommit console to manage the list of email addresses and endpoints subscribed to the topic or to disable notifications. <a name="how-to-repository-email-change-console"></a>

**To change notification settings**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the name of the repository where you want to configure notifications created before November 5, 2019. 

1. In the navigation pane, choose **Settings**, and then choose **Notifications**. If you see a banner informing you that you have notifications instead of notification rules, choose **Manage existing notifications**.

1. Choose **Edit**.

1. Make your changes, and then choose **Save**.

Disabling notifications is an easy way to temporarily prevent users from receiving emails about repository events. 

To permanently delete a notification created before November 5, 2019, follow the steps in [Delete notifications](how-to-repository-email-delete.md). <a name="how-to-repository-email-disable-console"></a>

**To disable notifications**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the name of the repository where you want to disable notifications. 

1. In the navigation pane, choose **Settings**, and then choose **Notifications**. Choose **Manage existing notifications**.

1. Choose **Edit**, and in **Event status**, use the slider to turn off **Enable notifications**. Choose **Save**. 

1. The event status changes to **Disabled**. No emails about events are sent. When you disable notifications, the CloudWatch Events rule for the repository is disabled automatically. Do not manually change its status in the CloudWatch Events console.

# Delete notifications


If you no longer want to use notifications created for a repository before November 5, 2019, you can delete the Amazon CloudWatch Events rule associated with the notification. That will automatically delete the notification. It does not delete any subscriptions or the Amazon SNS topic used for notifications. 

**Note**  
If you change the name of a repository from the console, notifications created before November 5, 2019 continue to work without modification. However, if you change the name of your repository from the command line or by using the API, notifications no longer work. The easiest way to restore notifications is to delete the notification settings and then configure them again.<a name="how-to-repository-email-delete-console"></a>

**To delete notification settings**

1. Open the CodeCommit console at [https://console.aws.amazon.com/codesuite/codecommit/home](https://console.aws.amazon.com/codesuite/codecommit/home).

1. In **Repositories**, choose the name of the repository where you want to remove notifications created before November 5, 2019. 

1. In the navigation pane, choose **Settings**, and then choose **Notifications**. If you see a banner informing you that you have notifications instead of notification rules, choose **Manage existing notifications**.

1. In **CloudWatch event rule**, copy the name of the rule that was created for the notification.

1. Sign in to the AWS Management Console and open the CloudWatch console at [https://console.aws.amazon.com/cloudwatch/](https://console.aws.amazon.com/cloudwatch/).

1. In **Events**, choose **Rules**. In **Name**, paste the name of the rule created for the notification. Choose the rule, and in **Actions**, choose **Delete**.

1. (Optional) To change or delete the Amazon SNS topic used for notifications after you delete notification settings, go to the Amazon SNS console at [https://console.aws.amazon.com/sns/v3/home](https://console.aws.amazon.com/sns/v3/home). For more information, see [Clean Up](https://docs.aws.amazon.com/sns/latest/dg/CleanUp.html) in [Amazon Simple Notification Service Developer Guide](https://docs.aws.amazon.com/sns/latest/dg/).