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 Antwort
1
Akzeptierte Antwort

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
EXPERTE
beantwortet vor 2 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten
  • This event is working for me. Thanks a lot!

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen