我正在尝试PutImage
使用 Cloudwatch 从特定 ECR 存储库捕获事件以触发 Lambda。
我的问题是 eventPattern 被键入为“字符串”:
export const myTestRepo = ECRTemplate('my-test-repo');
export const eventRule = new aws.cloudwatch.EventRule("putimagerule", {
eventPattern: JSON.stringify({
"detail-type": [
"AWS API Call via CloudTrail"
],
"source": ["aws.ecr"],
"detail": {
"eventName": ["PutImage"],
"repositoryName": [myTestRepo.repository.name]
}
}),
});
结果事件规则如下所示:
{
"detail":{
"eventName":[
"PutImage"
],
"repositoryName":[
"Calling [toJSON] on an [Output\u003cT\u003e] is not supported.\n\nTo get the value of an Output as a JSON value or JSON string consider either:\n 1: o.apply(v =\u003e v.toJSON())\n 2: o.apply(v =\u003e JSON.stringify(v))\n\nSee https://pulumi.io/help/outputs for more details.\nThis function may throw in a future version of @pulumi/pulumi."
]
},
"detail-type":[
"AWS API Call via CloudTrail"
],
"source":[
"aws.ecr"
]
}
对象myTestRepo
包含一个有效的存储库,并且不是问题的一部分,为什么它不包含在此处。
问:如何捕获PutImage
特定的存储库?