Customize the Notification Format for Pull Request State Change Using Amazon EventBridge Rule
Tags: aws, awseventbridge, awscodecommit, awssns
Published: 2023-07-15 14:33:05

“ I have checked the documents of AWS to customize the notification format for pull request state change in codecommit repo. So I got the Amazon Eventbridge Rule as a solution. Pricing of solution depends on codecommit repo, eventbridge rule and sns topic cost.”

Amazon EventBridge is a serverless event bus service that you can use to connect your applications with data from a variety of sources. EventBridge delivers a stream of real-time data from your applications, software as a service (SaaS) applications, and AWS services to targets such as AWS Lambda functions, HTTP invocation endpoints using API destinations, or event buses in other AWS accounts.

In this post, you will get to know how to customize the notification format for pull request state change using amazon eventbridge rule. Here I have used a sns topic, eventbridge rule and codecommit repository for notification format creation for pull request state change as create and merge using eventbridge rule.

#Prerequisites
You’ll need an Amazon SNS for this post. [Getting started with amazon SNS](https://aws.amazon.com/sns/getting-started/) provides instructions on how to create a topic and subscription.

You’ll need an AWS CodeCommit Repositories for this post. [Getting started with AWS CodeCommit](https://aws.amazon.com/codecommit/features/) provides instructions on how to create a codecommit repository. For this blog, I assume that I have a codecommit repository and a sns topic created.

#Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2uqfyjl5xs7yp0w7j4a.jpg)
The architecture diagram shows the overall deployment architecture with data flow, amazon eventbridge rule, aws codecommit repo, sns topic and mail box.

#Solution overview
The blog post consists of the following phases:

1. Create Eventbridge Rule with Required Details of Customize Mail Format
2. Output of Notification in Mail for Pull Request Creation and Merge

I have sns topic with subscription and codecommit repository with branch as below →
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1z2aor7c0joem6i6kkru.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqq4amdjl2ucbwvfcaz9.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8d6nstqa1qlrk2z3p29o.png)

##Phase 1: Create Eventbridge Rule with Required Details of Customize Mail Format
1. Open the Eventbridge console and create a eventbridge rule with required rule detail, build event pattern with codecommit service, define target as sns topic with additional settings for customize mail format.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w22d5af13qjb1m4f31q9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2d2umal85vxpsdudlgkh.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmdee2wx4acxd9mgobkc.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esubbu1t78hmj4nxk8gc.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4kp4tmzpy9pofv2q83k.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bwfaorzsdonry9bo93rx.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xlcbexa1ztaunv9uj3hr.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ffn79pi6vkfbp32ohqda.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3z7u7sr3p8so1lhl1w4y.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fpd4llmjn4b9zze19aq.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg6zmxvpb3pz657wh6aa.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kwdkxzdp8ufsobuhtlc6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3jxvpf4egmyp75izu9qv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iozjyh3kyu1btl8kloet.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7wxzp54t2u42hj863hud.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gd99m0nqggz6itw3v0t6.png)

##Phase 2: Output of Notification in Mail for Pull Request Creation and Merge

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nuhcwkofw6c5vbrvpyhd.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5hcfmtbjhb4zwf6s25nv.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7126nzpdw5anywwuvm5s.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ew7lwnw2ri7fgjeo188g.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v853rnmhv0lkotsgin6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dck4mr403ze4qkey0vd4.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z84kdt124lty7pf29lr6.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2j0vn8f1kxcr3j0v57y.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulzku3s3le48ik54q0ge.png)

#Clean-up
Delete SNS Topic, Eventbridge Rule and CodeCommit Repository.

#Pricing
I review the pricing and estimated cost of this example. 

Cost of Simple Notification Service = Free for notifications and requests = $0.0

Cost of CodeCommit = $0.00 for first 5 CodeCommit users = $0.0

Cost of EventBridge Rules = $0.0 

Total Cost = $0.0

#Summary
In this post, I showed “how to customize the notification format for pull request state change using amazon eventbridge rule”.

For more details on Amazon EventBridge Rules, Checkout Get started Amazon EventBridge Rules, open the [Amazon EventBridge console](https://us-east-1.console.aws.amazon.com/events/home?region=us-east-1#/). To learn more, read the [Amazon EventBridge documentation](https://docs.aws.amazon.com/eventbridge/?id=docs_gateway).

Thanks for reading!

Connect with me: [Linkedin](https://www.linkedin.com/in/gargee-bhatnagar-6b7223114)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38sdi4nsp89fnui8h7dk.png)