Lambda Function Not Triggering on Merge Events for Specific Branches Using CloudWatch Event Pattern

0

Hello all,

I'm currently working on setting up a Lambda function to be triggered by merge events on the dev, release, and main branches of my CodeCommit repository. I've chosen to use CloudWatch (EventBridge) rules for this purpose. However, despite following the setup process as documented, my Lambda function does not seem to be triggered when merges occur into these branches.

Below is the event pattern I'm using in my CloudWatch rule:

{ "source": ["aws.codecommit"], "detail-type": ["CodeCommit Pull Request State Change"], "resources": ["arn:aws:codecommit:region:account-id:repository-name"], detail: { event: ["pullRequestMerged"], destinationReference: [ "refs/heads/release", "refs/heads/main", "refs/heads/develop", ], mergeOption: ["FAST_FORWARD_MERGE"], }, } I've double-checked the following:

  • The ARN for the repository is correct and matches the repository where the merges are occurring.
  • The Lambda function has the necessary permissions to be invoked by CloudWatch Events.
  • I've manually tested the Lambda function to ensure it works as expected when invoked directly.
  • Despite this, merges into dev, release, or main do not trigger the Lambda function.

Here are some additional details that might be relevant:

  • The merges are being done through the AWS CodeCommit console and via git command line, both with the same non-triggering result.
  • There are no errors in the CloudWatch Logs that indicate a problem with the rule or the Lambda function.

Questions:

  • Is the event pattern correctly configured to capture merge events on these specific branches?
  • Are there known issues or limitations with CloudWatch Events and CodeCommit integration that I might be overlooking?
  • Could there be a delay or configuration setting I'm missing that affects the triggering of the Lambda function?

Any advice, insights, or recommendations on how to troubleshoot and resolve this issue would be greatly appreciated.

Thank you in advance for your help!

1개 답변
1
수락된 답변

Hello.

Looking at the document below, I thought there was no event called "pullRequestMerged".
https://docs.aws.amazon.com/codecommit/latest/userguide/monitoring-events.html

I thought that if I do the following, Lambda will run when a merge occurs.

{
  "source": ["aws.codecommit"],
  "detail-type": ["CodeCommit Repository State Change"],
  "resources": ["arn:aws:codecommit:region:account-id:repository-name"],
  "detail": {
    "event": ["referenceUpdated"],
    "referenceType": ["branch"],
    "referenceName": ["release", main, develop]
  }
}
profile picture
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
  • This event is working for me. Thanks a lot!

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠