1
votes

I am attempting to get a CloudWatch Event to work for a specific CodeBuild project on Build State Change, but it does not seem to take. It works fine if I remove the resource, but then it also triggers on any CodeBuild project. I have something similar working for a specific CodeCommit repository. Am I doing something wrong or is this not implemented for CodeBuild?

{
  "detail-type": [
    "CodeBuild Build State Change"
  ],
  "source": [
    "aws.codebuild"
  ],
  "resources": [
    "arn:aws:codebuild:us-east-2:1234567890:build/project-name:*"
  ]
}
1

1 Answers

3
votes

To create CWE rule for specific CodeBuild project, use 'detail.project-name' filter in your CWE rule

{
 "source": [ 
   "aws.codebuild"
 ], 
 "detail-type": [
   "CodeBuild Build State Change"
 ],
 "detail": {
   "project-name": [
      "project-name"
   ]
 }  

}

https://docs.aws.amazon.com/codebuild/latest/userguide/sample-build-notifications.html