I am trying to capture PutImage
event from a specific ECR repository using Cloudwatch to trigger a Lambda.
My problem is with eventPattern being typed as 'string':
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]
}
}),
});
and a resulting event rule looks like this:
{
"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"
]
}
Object myTestRepo
contains a valid Repository and is not a part of the problem that why it is not included here.
Q: How to catch PutImage
for a specific repository?