If you are receiving the aws payload in your continuous integration server (jenkins, travis, etc) and you are able to clone the repository (if you are going to buid your app) you will be able to get the message using git tool which is already installed if you are going to clone your repository
This is the notification payload from aws code commit trigger to my ci server:
{
"Type": "Notification",
"MessageId": "296892a1a77b",
"TopicArn": "arn:aws:sns:us-bar-1:123456:TopicFoo",
"Subject": "UPDATE: AWS CodeCommit us-bar-1 push: my-awesome-repo",
"Message": ".....",
"Timestamp": "2021-06-23T20:57:15.040Z",
"SignatureVersion": "1",
"SigningCertURL": "https://sns.us-bar-1.amazonaws.com/SimpleNotificationService-foo-.pem",
"UnsubscribeURL": "https://foo.bar"
}
Message field is stringified :s
{\"Records\":[{\"awsRegion\":\"us-bar-1\",\"codecommit\":{\"references\":[{\"commit\":\"fb28ebbec522cc403\",\"ref\":\"refs/heads/mybranch\"}]},\"customData\":null,\"eventId\":\"d1dab883\",\"eventName\":\"ReferenceChanges\",\"eventPartNumber\":1,\"eventSource\":\"aws:codecommit\",\"eventSourceARN\":\"arn:aws:codecommit:us-bar-1:123456:my-awesome-repo\",\"eventTime\":\"2021-06-23T20:57:15.005+0000\",\"eventTotalParts\":1,\"eventTriggerConfigId\":\"e4ea5f3bec6c\",\"eventTriggerName\":\"my_ci_server_notification\",\"eventVersion\":\"1.0\",\"userIdentityARN\":\"arn:aws:iam::123456:user/jane_doe\"}]}
But replacing \"
by "
, We will get a readable json
{
"Records": [{
"awsRegion": "us-bar-1",
"codecommit": {
"references": [{
"commit": "fb28ebbec522cc403",
"ref": "refs/heads/mybranch"
}]
},
"customData": null,
"eventId": "d1dab883",
"eventName": "ReferenceChanges",
"eventPartNumber": 1,
"eventSource": "aws:codecommit",
"eventSourceARN": "arn:aws:codecommit:us-bar-1:123456:my-awesome-repo",
"eventTime": "2021-06-23T20:57:15.005+0000",
"eventTotalParts": 1,
"eventTriggerConfigId": "e4ea5f3bec6c",
"eventTriggerName": "my_ci_server_notification",
"eventVersion": "1.0",
"userIdentityARN": "arn:aws:iam::123456:user/jane_doe"
}]
}
In which we can extract the commit id in the section: references.commit
"references": [{
"commit": "fb28ebbec522cc403",
"ref": "refs/heads/mybranch"
}]
And finally get the message using git shell tool :S
git log --format=%B -n 1 fb28ebbec522cc403