Skip to content

Commit 9946ab0

Browse files
fix(lambda-event-source): allow dynamodb filtering on boolean value (#31011)
### Issue # (if applicable) Closes #30734 ### Reason for this change Filtering on boolean values was not possible ### Description of changes `lambda.FilterRule.isEqual(...)` now accepts `boolean` values ### Description of how you validated changes Added a unit test and integration test ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent e3e5e1c commit 9946ab0

12 files changed

+849
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-boolean-filter.js.snapshot/DynamoDBFilterBooleanDefaultTestDeployAssert8561382F.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-boolean-filter.js.snapshot/DynamoDBFilterBooleanDefaultTestDeployAssert8561382F.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-boolean-filter.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-boolean-filter.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-boolean-filter.js.snapshot/lambda-event-source-filter-boolean-dynamodb.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"Resources": {
3+
"FServiceRole3AC82EE1": {
4+
"Type": "AWS::IAM::Role",
5+
"Properties": {
6+
"AssumeRolePolicyDocument": {
7+
"Statement": [
8+
{
9+
"Action": "sts:AssumeRole",
10+
"Effect": "Allow",
11+
"Principal": {
12+
"Service": "lambda.amazonaws.com"
13+
}
14+
}
15+
],
16+
"Version": "2012-10-17"
17+
},
18+
"ManagedPolicyArns": [
19+
{
20+
"Fn::Join": [
21+
"",
22+
[
23+
"arn:",
24+
{
25+
"Ref": "AWS::Partition"
26+
},
27+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
28+
]
29+
]
30+
}
31+
]
32+
}
33+
},
34+
"FServiceRoleDefaultPolicy17A19BFA": {
35+
"Type": "AWS::IAM::Policy",
36+
"Properties": {
37+
"PolicyDocument": {
38+
"Statement": [
39+
{
40+
"Action": "dynamodb:ListStreams",
41+
"Effect": "Allow",
42+
"Resource": "*"
43+
},
44+
{
45+
"Action": [
46+
"dynamodb:DescribeStream",
47+
"dynamodb:GetRecords",
48+
"dynamodb:GetShardIterator"
49+
],
50+
"Effect": "Allow",
51+
"Resource": {
52+
"Fn::GetAtt": [
53+
"TD925BC7E",
54+
"StreamArn"
55+
]
56+
}
57+
}
58+
],
59+
"Version": "2012-10-17"
60+
},
61+
"PolicyName": "FServiceRoleDefaultPolicy17A19BFA",
62+
"Roles": [
63+
{
64+
"Ref": "FServiceRole3AC82EE1"
65+
}
66+
]
67+
}
68+
},
69+
"FC4345940": {
70+
"Type": "AWS::Lambda::Function",
71+
"Properties": {
72+
"Code": {
73+
"ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}"
74+
},
75+
"Handler": "index.handler",
76+
"Role": {
77+
"Fn::GetAtt": [
78+
"FServiceRole3AC82EE1",
79+
"Arn"
80+
]
81+
},
82+
"Runtime": "nodejs18.x"
83+
},
84+
"DependsOn": [
85+
"FServiceRoleDefaultPolicy17A19BFA",
86+
"FServiceRole3AC82EE1"
87+
]
88+
},
89+
"FDynamoDBEventSourcelambdaeventsourcefilterbooleandynamodbT2161ED824BB5B64C": {
90+
"Type": "AWS::Lambda::EventSourceMapping",
91+
"Properties": {
92+
"BatchSize": 5,
93+
"EventSourceArn": {
94+
"Fn::GetAtt": [
95+
"TD925BC7E",
96+
"StreamArn"
97+
]
98+
},
99+
"FilterCriteria": {
100+
"Filters": [
101+
{
102+
"Pattern": "{\"eventName\":[\"INSERT\"],\"dynamodb\":{\"NewImage\":{\"id\":{\"BOOL\":[true]}}}}"
103+
}
104+
]
105+
},
106+
"FunctionName": {
107+
"Ref": "FC4345940"
108+
},
109+
"StartingPosition": "LATEST"
110+
}
111+
},
112+
"TD925BC7E": {
113+
"Type": "AWS::DynamoDB::Table",
114+
"Properties": {
115+
"AttributeDefinitions": [
116+
{
117+
"AttributeName": "id",
118+
"AttributeType": "S"
119+
}
120+
],
121+
"KeySchema": [
122+
{
123+
"AttributeName": "id",
124+
"KeyType": "HASH"
125+
}
126+
],
127+
"ProvisionedThroughput": {
128+
"ReadCapacityUnits": 5,
129+
"WriteCapacityUnits": 5
130+
},
131+
"StreamSpecification": {
132+
"StreamViewType": "NEW_IMAGE"
133+
}
134+
},
135+
"UpdateReplacePolicy": "Delete",
136+
"DeletionPolicy": "Delete"
137+
}
138+
},
139+
"Parameters": {
140+
"BootstrapVersion": {
141+
"Type": "AWS::SSM::Parameter::Value<String>",
142+
"Default": "/cdk-bootstrap/hnb659fds/version",
143+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
144+
}
145+
},
146+
"Rules": {
147+
"CheckBootstrapVersion": {
148+
"Assertions": [
149+
{
150+
"Assert": {
151+
"Fn::Not": [
152+
{
153+
"Fn::Contains": [
154+
[
155+
"1",
156+
"2",
157+
"3",
158+
"4",
159+
"5"
160+
],
161+
{
162+
"Ref": "BootstrapVersion"
163+
}
164+
]
165+
}
166+
]
167+
},
168+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
169+
}
170+
]
171+
}
172+
}
173+
}

0 commit comments

Comments
 (0)