7

I would like to know how to customize a slack integration between AWS Code Commit and Slack.

Currently my setup uses an SNS topic connected to an AWS Chatbot. I followed instructions at: https://docs.aws.amazon.com/codecommit/latest/userguide/notification-rule-create.html

Currently the notifications on slack do not display relevant details like the author and message.

Eg:

enter image description here

Thanks in advance!

ipegasus
  • 14,796
  • 9
  • 52
  • 76
  • input transformer may solve this problem - a sample is here https://stackoverflow.com/a/59287292/2188922 – Ersoy May 25 '20 at 22:17
  • 3
    have you ever solved this? – Z T Apr 23 '21 at 16:47
  • Hi @ZoltanSzabo It was solved via Amazon SNS service: https://aws.amazon.com/about-aws/whats-new/2020/04/receive-notifications-for-aws-codebuild-codecommit-codedeploy-codepipeline-in-slack/ I hope it helps – ipegasus Apr 24 '21 at 16:42
  • Would you care to share some steps to configure input transformer for same? I am received the same notification in slack. Input transformer is change somehow. Not its under `Amazon EventBride`. And its very confusing. – Santosh Aug 29 '22 at 08:46

2 Answers2

0

Unfortunately the GitPush event only contains the commit id and the branch name:

  "eventName": "GitPush",
  "awsRegion": "us-east-1",
  "sourceIPAddress": "52.21.1.64",
  "userAgent": "git/2.20.1 (Apple Git-117)",
  "requestParameters": {
    "references": [
      {
        "commit": "758822355756e0badd633debe441792",
        "ref": "refs/heads/master"
      }
    ]
  },

Probably one way is to invoke a Lambda on GitPush CloudWatch event, then do some further interrogation in the Lambda to find out the author of the commit:

$ git log --format=%B -n 1 <commit>
shariqmaws
  • 8,152
  • 1
  • 16
  • 35
0

I have created a Lambda function to make that thing work. I have post my answer here. I hope it helps.

https://stackoverflow.com/a/73537593/1682525

After lambda function integration and added trigger to codecommit. I could see commit details in Slack channel feed. You can customized the feed response too. The code in Lambda is preety straight forward.

enter image description here

I hope it helpe someone.

Santosh
  • 3,477
  • 5
  • 37
  • 75