AWS 使用EventBridge监听CodeCommit提交事件并触发CodeBuild
- 写入你的规则名
2. 选择other,接着滑到下面,在Event Pattern当中输入JSON
- resources就是监听你的codecommit repo
- referenceName就是监听branch
{
"source": ["aws.codecommit"],
"detail-type": ["CodeCommit Repository State Change"],
"resources": ["arn:aws:codecommit:ap-southeast-1:12312:test3"],
"detail": {
"event": ["referenceCreated", "referenceUpdated"],
"referenceType": ["branch"],
"referenceName": ["main"]
}
}
3. 设置触发的CodeBuild Project, 需要输入所需触发的CodeBuild Project ARN
– 如果是新创建的话,就需要创建role,否则没有权限start build
4. 最后去到Step5就创建完成了,自动创建的role是只能触发你指定的CodeBuild Project, 如果不想创建太多role的话,也可以去更改自动创建的role变成可以触发所有的project,那么就能重用同一个role了
– 去到IAM 改role,改成以下的JSON
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"codebuild:StartBuild"
],
"Resource": "*"
}
]
}
Facebook评论