This is the format of my JSON events, incoming from another AWS account EventBridge into my own AWS account EventBridge bus.
{
"version": "0",
"id": "e53c5be7-0ea4-4590-1ed5-4c4db642401c",
"detail-type": "Event from aws:dynamodb",
"source": "Pipe dynamodb-pipe-my-service-dev",
"account": "000000000000",
"time": "2023-08-17T12:51:39Z",
"region": "us-east-1",
"resources": [],
"detail": {
"eventID": "eea64ea701c786e930845b8397e34c57",
"eventName": "MODIFY",
"eventVersion": "1.1",
"eventSource": "aws:dynamodb",
"awsRegion": "us-east-1",
"dynamodb": {
"ApproximateCreationDateTime": 1692276699,
"Keys": {
"SK": {
"S": "TYPE#CONFIG"
},
"PK": {
"S": "PROJECT#2HuNAorgCkkyAL6vIEUduu8G2Ya"
}
},
"NewImage": {...}
...
The changing part is SK and PK.
Sometimes [ SK = TYPE#PLAN, PK = "SERVICE#123" ].
Sometimes [ SK = TYPE#CONFIG, PK = "PROJECT#321" ].
I want only the latter to be forwarded to my target.
My aws_cloudwatch_event_rule
features:
event_pattern = jsonencode({
"detail" : {
"dynamodb" : {
"Keys" : {
"PK" : {
"S" : {
"prefix" : ["PROJECT#"]
}
}
}
}
}
})
Unfortunately, no events reach my target.
While, with a wildcard filter like {"source" : [{"prefix" : ""}]
both event types (all, in fact) are forwarded.
Can you please help me fix my event_pattern in order to get only PK starting w/ PROJECT#
?
2
Answers
Your
prefix
syntax is incorrect, try:You need to drop the
detail
aspect which is not relevant on a DynamoDB event, you should be able to access the params like this: