Skip to content

Commit ed46c9e

Browse files
authored
Merge branch 'main' into release-v1.91.0
2 parents e8d7b0a + 690bfff commit ed46c9e

File tree

13 files changed

+140
-0
lines changed

13 files changed

+140
-0
lines changed

.cfnlintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ ignore_templates:
8585
- tests/translator/output/**/function_with_event_dest_conditional.json
8686
- tests/translator/output/**/function_with_event_schedule_state.json
8787
- tests/translator/output/**/function_with_file_system_config.json
88+
- tests/translator/output/**/function_with_event_filtering.json # TODO: remove once Event's KmsKeyArn is available
8889
- tests/translator/output/**/function_with_function_url_config_conditions.json
8990
- tests/translator/output/**/function_with_globals_role_path.json
9091
- tests/translator/output/**/function_with_intrinsic_architecture.json
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"LogicalResourceId": "BasicFunctionWithEventFilteringUsingKmsKeyArn",
4+
"ResourceType": "AWS::Lambda::Function"
5+
},
6+
{
7+
"LogicalResourceId": "BasicFunctionWithEventFilteringUsingKmsKeyArnRole",
8+
"ResourceType": "AWS::IAM::Role"
9+
},
10+
{
11+
"LogicalResourceId": "MyKey",
12+
"ResourceType": "AWS::KMS::Key"
13+
},
14+
{
15+
"LogicalResourceId": "MySqsQueue",
16+
"ResourceType": "AWS::SQS::Queue"
17+
},
18+
{
19+
"LogicalResourceId": "BasicFunctionWithEventFilteringUsingKmsKeyArnMySqsEvent",
20+
"ResourceType": "AWS::Lambda::EventSourceMapping"
21+
}
22+
]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Resources:
2+
BasicFunctionWithEventFilteringUsingKmsKeyArn:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
Handler: index.handler
6+
Runtime: nodejs18.x
7+
CodeUri: ${codeuri}
8+
MemorySize: 128
9+
Events:
10+
MySqsEvent:
11+
Type: SQS
12+
Properties:
13+
Queue: !GetAtt MySqsQueue.Arn
14+
FilterCriteria:
15+
Filters:
16+
- Pattern: '{ "body" : { "RequestCode" : [ "BBBB" ] } }'
17+
KmsKeyArn: !GetAtt MyKey.Arn
18+
19+
MyKey:
20+
Type: AWS::KMS::Key
21+
Properties:
22+
Description: A sample key
23+
KeyPolicy:
24+
Version: '2012-10-17'
25+
Id: key-default-1
26+
Statement:
27+
- Sid: Allow administration of the key
28+
Effect: Allow
29+
Principal:
30+
AWS: !Sub arn:${AWS::Partition}:iam::${AWS::AccountId}:root
31+
Action:
32+
- kms:*
33+
Resource: '*'
34+
- Sid: Allow encryption/decryption access to Lambda Service Principal
35+
Effect: Allow
36+
Principal:
37+
Service: lambda.amazonaws.com
38+
Action: kms:Decrypt
39+
Resource: '*'
40+
41+
MySqsQueue:
42+
Type: AWS::SQS::Queue
43+
44+
Metadata:
45+
SamTransformTest: true

integration/single/test_basic_function.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,28 @@ def test_basic_function_with_tracing(self):
274274
"Expecting tracing config mode to be set to PassThrough.",
275275
)
276276

277+
# TODO: add the integration test back after the feature launch on 06/05
278+
# @skipIf(current_region_does_not_support([KMS]), "KMS is not supported in this testing region")
279+
# def test_basic_function_with_event_filtering_using_kms(self):
280+
# """
281+
# Creates a basic lambda function with KMS key arn
282+
# """
283+
# self.create_and_verify_stack("single/basic_function_with_event_filtering_using_kms")
284+
285+
# lambda_function_name = self.get_physical_id_by_type("AWS::Lambda::Function")
286+
# event_source_mappings = self.client_provider.lambda_client.list_event_source_mappings(
287+
# FunctionName=lambda_function_name
288+
# )
289+
290+
# event_source_mapping = event_source_mappings["EventSourceMappings"][0]
291+
# function_uuid = event_source_mapping["UUID"]
292+
293+
# event_source_mapping_config = self.client_provider.lambda_client.get_event_source_mapping(UUID=function_uuid)
294+
295+
# kms_key_arn = event_source_mapping_config["KMSKeyArn"]
296+
297+
# self.assertIsNotNone(kms_key_arn, "Expecting KmsKeyArn to be set.")
298+
277299
def _assert_invoke(self, lambda_client, function_name, qualifier=None, expected_status_code=200):
278300
"""
279301
Assert if a Lambda invocation returns the expected status code

samtranslator/internal/schema_source/aws_serverless_function.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class KinesisEventProperties(BaseModel):
169169
Enabled: Optional[PassThroughProp] = kinesiseventproperties("Enabled")
170170
FilterCriteria: Optional[PassThroughProp] = kinesiseventproperties("FilterCriteria")
171171
FunctionResponseTypes: Optional[PassThroughProp] = kinesiseventproperties("FunctionResponseTypes")
172+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
172173
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = kinesiseventproperties("MaximumBatchingWindowInSeconds")
173174
MaximumRecordAgeInSeconds: Optional[PassThroughProp] = kinesiseventproperties("MaximumRecordAgeInSeconds")
174175
MaximumRetryAttempts: Optional[PassThroughProp] = kinesiseventproperties("MaximumRetryAttempts")
@@ -191,6 +192,7 @@ class DynamoDBEventProperties(BaseModel):
191192
Enabled: Optional[PassThroughProp] = dynamodbeventproperties("Enabled")
192193
FilterCriteria: Optional[PassThroughProp] = dynamodbeventproperties("FilterCriteria")
193194
FunctionResponseTypes: Optional[PassThroughProp] = dynamodbeventproperties("FunctionResponseTypes")
195+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
194196
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = dynamodbeventproperties(
195197
"MaximumBatchingWindowInSeconds"
196198
)
@@ -235,6 +237,7 @@ class SQSEventProperties(BaseModel):
235237
Enabled: Optional[PassThroughProp] = sqseventproperties("Enabled")
236238
FilterCriteria: Optional[PassThroughProp] = sqseventproperties("FilterCriteria")
237239
FunctionResponseTypes: Optional[PassThroughProp] = sqseventproperties("FunctionResponseTypes")
240+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
238241
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = sqseventproperties("MaximumBatchingWindowInSeconds")
239242
Queue: PassThroughProp = sqseventproperties("Queue")
240243
ScalingConfig: Optional[PassThroughProp] # Update docs when live
@@ -406,6 +409,7 @@ class HttpApiEvent(BaseModel):
406409
class MSKEventProperties(BaseModel):
407410
ConsumerGroupId: Optional[PassThroughProp] = mskeventproperties("ConsumerGroupId")
408411
FilterCriteria: Optional[PassThroughProp] = mskeventproperties("FilterCriteria")
412+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
409413
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mskeventproperties("MaximumBatchingWindowInSeconds")
410414
StartingPosition: Optional[PassThroughProp] = mskeventproperties("StartingPosition")
411415
StartingPositionTimestamp: Optional[PassThroughProp] = mskeventproperties("StartingPositionTimestamp")
@@ -426,6 +430,7 @@ class MQEventProperties(BaseModel):
426430
DynamicPolicyName: Optional[bool] = mqeventproperties("DynamicPolicyName")
427431
Enabled: Optional[PassThroughProp] = mqeventproperties("Enabled")
428432
FilterCriteria: Optional[PassThroughProp] = mqeventproperties("FilterCriteria")
433+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
429434
MaximumBatchingWindowInSeconds: Optional[PassThroughProp] = mqeventproperties("MaximumBatchingWindowInSeconds")
430435
Queues: PassThroughProp = mqeventproperties("Queues")
431436
SecretsManagerKmsKeyId: Optional[str] = mqeventproperties("SecretsManagerKmsKeyId")
@@ -445,6 +450,7 @@ class SelfManagedKafkaEventProperties(BaseModel):
445450
KafkaBootstrapServers: Optional[List[SamIntrinsicable[str]]] = selfmanagedkafkaeventproperties(
446451
"KafkaBootstrapServers"
447452
)
453+
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation
448454
SourceAccessConfigurations: PassThroughProp = selfmanagedkafkaeventproperties("SourceAccessConfigurations")
449455
StartingPosition: Optional[PassThroughProp] # TODO: add documentation
450456
StartingPositionTimestamp: Optional[PassThroughProp] # TODO: add documentation

samtranslator/model/eventsources/pull.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta):
5252
"FunctionResponseTypes": PropertyType(False, IS_LIST),
5353
"KafkaBootstrapServers": PropertyType(False, IS_LIST),
5454
"FilterCriteria": PropertyType(False, IS_DICT),
55+
"KmsKeyArn": PassThroughProperty(False),
5556
"ConsumerGroupId": PropertyType(False, IS_STR),
5657
"ScalingConfig": PropertyType(False, IS_DICT),
5758
}
@@ -74,6 +75,7 @@ class PullEventSource(ResourceMacro, metaclass=ABCMeta):
7475
FunctionResponseTypes: Optional[List[Any]]
7576
KafkaBootstrapServers: Optional[List[Any]]
7677
FilterCriteria: Optional[Dict[str, Any]]
78+
KmsKeyArn: Optional[Intrinsicable[str]]
7779
ConsumerGroupId: Optional[Intrinsicable[str]]
7880
ScalingConfig: Optional[Dict[str, Any]]
7981

@@ -141,6 +143,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def] # noqa: P
141143
lambda_eventsourcemapping.TumblingWindowInSeconds = self.TumblingWindowInSeconds
142144
lambda_eventsourcemapping.FunctionResponseTypes = self.FunctionResponseTypes
143145
lambda_eventsourcemapping.FilterCriteria = self.FilterCriteria
146+
lambda_eventsourcemapping.KmsKeyArn = self.KmsKeyArn
144147
lambda_eventsourcemapping.ScalingConfig = self.ScalingConfig
145148
self._validate_filter_criteria()
146149

samtranslator/model/lambda_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ class LambdaEventSourceMapping(Resource):
118118
"FunctionResponseTypes": GeneratedProperty(),
119119
"SelfManagedEventSource": GeneratedProperty(),
120120
"FilterCriteria": GeneratedProperty(),
121+
"KmsKeyArn": GeneratedProperty(),
121122
"AmazonManagedKafkaEventSourceConfig": GeneratedProperty(),
122123
"SelfManagedKafkaEventSourceConfig": GeneratedProperty(),
123124
"ScalingConfig": GeneratedProperty(),

samtranslator/schema/schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274745,6 +274745,9 @@
274745274745
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
274746274746
"title": "FunctionResponseTypes"
274747274747
},
274748+
"KmsKeyArn": {
274749+
"$ref": "#/definitions/PassThroughProp"
274750+
},
274748274751
"MaximumBatchingWindowInSeconds": {
274749274752
"allOf": [
274750274753
{
@@ -275489,6 +275492,9 @@
275489275492
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
275490275493
"title": "FunctionResponseTypes"
275491275494
},
275495+
"KmsKeyArn": {
275496+
"$ref": "#/definitions/PassThroughProp"
275497+
},
275492275498
"MaximumBatchingWindowInSeconds": {
275493275499
"allOf": [
275494275500
{
@@ -276052,6 +276058,9 @@
276052276058
"markdownDescription": "A object that defines the criteria that determines whether Lambda should process an event\\. For more information, see [AWS Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) in the *AWS Lambda Developer Guide*\\. \n*Type*: [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FilterCriteria`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
276053276059
"title": "FilterCriteria"
276054276060
},
276061+
"KmsKeyArn": {
276062+
"$ref": "#/definitions/PassThroughProp"
276063+
},
276055276064
"MaximumBatchingWindowInSeconds": {
276056276065
"allOf": [
276057276066
{
@@ -276145,6 +276154,9 @@
276145276154
"markdownDescription": "A object that defines the criteria that determines whether Lambda should process an event\\. For more information, see [AWS Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) in the *AWS Lambda Developer Guide*\\. \n*Type*: [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FilterCriteria`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
276146276155
"title": "FilterCriteria"
276147276156
},
276157+
"KmsKeyArn": {
276158+
"$ref": "#/definitions/PassThroughProp"
276159+
},
276148276160
"MaximumBatchingWindowInSeconds": {
276149276161
"allOf": [
276150276162
{
@@ -276771,6 +276783,9 @@
276771276783
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [ Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n *Valid values*: `ReportBatchItemFailures` \n *Type*: List \n *Required*: No \n *AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
276772276784
"title": "FunctionResponseTypes"
276773276785
},
276786+
"KmsKeyArn": {
276787+
"$ref": "#/definitions/PassThroughProp"
276788+
},
276774276789
"MaximumBatchingWindowInSeconds": {
276775276790
"allOf": [
276776276791
{
@@ -276987,6 +277002,9 @@
276987277002
"title": "KafkaBootstrapServers",
276988277003
"type": "array"
276989277004
},
277005+
"KmsKeyArn": {
277006+
"$ref": "#/definitions/PassThroughProp"
277007+
},
276990277008
"SourceAccessConfigurations": {
276991277009
"allOf": [
276992277010
{

schema_source/sam.schema.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@
974974
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
975975
"title": "FunctionResponseTypes"
976976
},
977+
"KmsKeyArn": {
978+
"$ref": "#/definitions/PassThroughProp"
979+
},
977980
"MaximumBatchingWindowInSeconds": {
978981
"allOf": [
979982
{
@@ -1736,6 +1739,9 @@
17361739
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-kinesis.html#services-kinesis-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n*Valid values*: `ReportBatchItemFailures` \n*Type*: List \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
17371740
"title": "FunctionResponseTypes"
17381741
},
1742+
"KmsKeyArn": {
1743+
"$ref": "#/definitions/PassThroughProp"
1744+
},
17391745
"MaximumBatchingWindowInSeconds": {
17401746
"allOf": [
17411747
{
@@ -2299,6 +2305,9 @@
22992305
"markdownDescription": "A object that defines the criteria that determines whether Lambda should process an event\\. For more information, see [AWS Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) in the *AWS Lambda Developer Guide*\\. \n*Type*: [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FilterCriteria`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
23002306
"title": "FilterCriteria"
23012307
},
2308+
"KmsKeyArn": {
2309+
"$ref": "#/definitions/PassThroughProp"
2310+
},
23022311
"MaximumBatchingWindowInSeconds": {
23032312
"allOf": [
23042313
{
@@ -2392,6 +2401,9 @@
23922401
"markdownDescription": "A object that defines the criteria that determines whether Lambda should process an event\\. For more information, see [AWS Lambda event filtering](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) in the *AWS Lambda Developer Guide*\\. \n*Type*: [FilterCriteria](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) \n*Required*: No \n*AWS CloudFormation compatibility*: This property is passed directly to the [`FilterCriteria`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-filtercriteria.html) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
23932402
"title": "FilterCriteria"
23942403
},
2404+
"KmsKeyArn": {
2405+
"$ref": "#/definitions/PassThroughProp"
2406+
},
23952407
"MaximumBatchingWindowInSeconds": {
23962408
"allOf": [
23972409
{
@@ -2949,6 +2961,9 @@
29492961
"markdownDescription": "A list of the response types currently applied to the event source mapping\\. For more information, see [ Reporting batch item failures](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting) in the *AWS Lambda Developer Guide*\\. \n *Valid values*: `ReportBatchItemFailures` \n *Type*: List \n *Required*: No \n *AWS CloudFormation compatibility*: This property is passed directly to the [`FunctionResponseTypes`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-functionresponsetypes) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
29502962
"title": "FunctionResponseTypes"
29512963
},
2964+
"KmsKeyArn": {
2965+
"$ref": "#/definitions/PassThroughProp"
2966+
},
29522967
"MaximumBatchingWindowInSeconds": {
29532968
"allOf": [
29542969
{
@@ -3165,6 +3180,9 @@
31653180
"title": "KafkaBootstrapServers",
31663181
"type": "array"
31673182
},
3183+
"KmsKeyArn": {
3184+
"$ref": "#/definitions/PassThroughProp"
3185+
},
31683186
"SourceAccessConfigurations": {
31693187
"allOf": [
31703188
{

tests/translator/input/function_with_event_filtering.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Resources:
5858
FilterCriteria:
5959
Filters:
6060
- Pattern: '{"name": "value"}'
61+
KmsKeyArn: arn:aws:kms:us-west-2:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab
6162
MyMQQueue:
6263
Type: MQ
6364
Properties:

0 commit comments

Comments
 (0)