How to create an AWS Cloudwatch event that runs Codebuild when a pull request is created in CodeCommit?

Viewed 513

I want to create a Cloudwatch event that runs a Codebuild project every time a pull request is made on a CodeCommit branch. However, the event I made is not triggering upon creation of the pull request on the master branch. Hope you guys could give me some advice on this.

Below is the event pattern of the event rule that I made:

{
  "source": [
    "aws.codecommit"
  ],
  "detail-type": [
    "CodeCommit Pull Request State Change"
  ],
  "resources": [
    "arn:aws:codecommit:XX-XX-1:XXX:dev-test"
  ],
  "detail": {
    "event": [
      "pullRequestCreated"
    ],
    "referenceType": [
      "branch"
    ],
    "referenceName": [
      "master"
    ]
  }
}
1 Answers

Your event does not look right to me. I would try using:

{
  "source": [
    "aws.codecommit"
  ],
  "detail-type": [
    "CodeCommit Pull Request State Change"
  ],
  "detail": {
    "event": [
      "pullRequestCreated"
    ],
    "repositoryNames": [
      "<your-repo>"
    ]
  }
}
Related