Skip to content

Commit 9820834

Browse files
authored
Merge pull request #2471 from aws/release-v1.50.0
Release 1.50.0 (to develop)
2 parents 27b089e + 8ef69cb commit 9820834

25 files changed

+704
-16
lines changed

docs/cloudformation_compatibility.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,28 @@ SourceAccessConfigurations All
120120

121121
MSK
122122
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123-
======================== ================================== ========================
124-
Property Name Intrinsic(s) Supported Reasons
125-
======================== ================================== ========================
126-
Stream All
127-
Topics All
128-
StartingPosition All
129-
======================== ================================== ========================
123+
================================ ================================== ========================
124+
Property Name Intrinsic(s) Supported Reasons
125+
================================ ================================== ========================
126+
MaximumBatchingWindowInSeconds All
127+
Stream All
128+
Topics All
129+
StartingPosition All
130+
ConsumerGroupId All
131+
================================ ================================== ========================
132+
133+
SelfManagedKafka
134+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135+
================================ ================================== ========================
136+
Property Name Intrinsic(s) Supported Reasons
137+
================================ ================================== ========================
138+
BatchSize All
139+
Topics All
140+
KafkaBootstrapServers All
141+
SourceAccessConfigurations All
142+
Enabled All
143+
ConsumerGroupId All
144+
================================ ================================= ========================
130145

131146
DynamoDB
132147
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

integration/combination/test_api_with_authorizer_apikey.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ def test_authorizer_apikey(self):
1919
apigw_client = self.client_provider.api_client
2020

2121
authorizers = apigw_client.get_authorizers(restApiId=rest_api_id)["items"]
22-
lambda_authorizer_uri = (
23-
"arn:aws:apigateway:"
24-
+ self.my_region
25-
+ ":lambda:path/2015-03-31/functions/"
26-
+ stack_outputs["AuthorizerFunctionArn"]
27-
+ "/invocations"
22+
23+
lambda_authorizer_uri = "arn:{}:apigateway:{}:lambda:path/2015-03-31/functions/{}/invocations".format(
24+
self.partition, self.my_region, stack_outputs["AuthorizerFunctionArn"]
2825
)
2926

3027
lambda_token_authorizer = get_authorizer_by_name(authorizers, "MyLambdaTokenAuth")

integration/combination/test_function_with_self_managed_kafka.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from unittest.case import skipIf
12
import pytest
23

34
from integration.helpers.base_test import BaseTest

integration/helpers/base_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ def setUpClass(cls):
7272
cls.code_dir = Path(cls.resources_dir, "code")
7373
cls.session = boto3.session.Session()
7474
cls.my_region = cls.session.region_name
75+
cls.partition = cls.session.get_partition_for_region(cls.my_region)
7576
cls.client_provider = ClientProvider()
7677
cls.file_to_s3_uri_map = read_test_config_file("file_to_s3_map_modified.json")
7778
cls.code_key_to_file = read_test_config_file("code_key_to_file_map.json")

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.49.0"
1+
__version__ = "1.50.0"

samtranslator/model/eventsources/pull.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class PullEventSource(ResourceMacro):
4646
"FunctionResponseTypes": PropertyType(False, is_type(list)),
4747
"KafkaBootstrapServers": PropertyType(False, is_type(list)),
4848
"FilterCriteria": PropertyType(False, is_type(dict)),
49+
"ConsumerGroupId": PropertyType(False, is_str()),
4950
}
5051

5152
def get_policy_arn(self):
@@ -112,6 +113,17 @@ def to_cloudformation(self, **kwargs):
112113
lambda_eventsourcemapping.SelfManagedEventSource = {
113114
"Endpoints": {"KafkaBootstrapServers": self.KafkaBootstrapServers}
114115
}
116+
if self.ConsumerGroupId:
117+
consumer_group_id_structure = {"ConsumerGroupId": self.ConsumerGroupId}
118+
if self.resource_type == "MSK":
119+
lambda_eventsourcemapping.AmazonManagedKafkaConfig = consumer_group_id_structure
120+
elif self.resource_type == "SelfManagedKafka":
121+
lambda_eventsourcemapping.SelfManagedKafkaConfig = consumer_group_id_structure
122+
else:
123+
raise InvalidEventException(
124+
self.logical_id,
125+
"Property ConsumerGroupId not defined for resource of type {}.".format(self.resource_type),
126+
)
115127

116128
destination_config_policy = None
117129
if self.DestinationConfig:

samtranslator/model/lambda_.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class LambdaEventSourceMapping(Resource):
8181
"FunctionResponseTypes": PropertyType(False, is_type(list)),
8282
"SelfManagedEventSource": PropertyType(False, is_type(dict)),
8383
"FilterCriteria": PropertyType(False, is_type(dict)),
84+
"AmazonManagedKafkaConfig": PropertyType(False, is_type(dict)),
85+
"SelfManagedKafkaConfig": PropertyType(False, is_type(dict)),
8486
}
8587

8688
runtime_attrs = {"name": lambda self: ref(self.logical_id)}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Resources:
2+
NotSupportedPullTrigger:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
CodeUri: s3://sam-demo-bucket/filtered_events.zip
6+
Handler: index.handler
7+
Runtime: nodejs16.x
8+
Events:
9+
DDBEvent:
10+
Type: DynamoDB
11+
Properties:
12+
Stream: arn:aws:dynamodb:us-east-1:012345678901:table/TestTable/stream/2015-05-11T21:21:33.291
13+
StartingPosition: TRIM_HORIZON
14+
ConsumerGroupId: consumergroup1
15+
16+
NotSupportedPushTrigger:
17+
Type: AWS::Serverless::Function
18+
Properties:
19+
CodeUri: s3://sam-demo-bucket/filtered_events.zip
20+
Handler: index.handler
21+
Runtime: nodejs16.x
22+
Events:
23+
SNSEvent:
24+
Type: SNS
25+
Properties:
26+
Topic: arn:aws:sns:us-east-1:123456789012:my_topic
27+
ConsumerGroupId: consumergroup1
28+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Parameters: {}
3+
4+
Resources:
5+
MyMskStreamProcessor:
6+
Type: AWS::Serverless::Function
7+
Properties:
8+
Runtime: nodejs12.x
9+
Handler: index.handler
10+
CodeUri: s3://sam-demo-bucket/kafka.zip
11+
Events:
12+
MyMskEvent:
13+
Type: MSK
14+
Properties:
15+
StartingPosition: LATEST
16+
Stream: !Sub arn:aws:kafka:${AWS::Region}:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2
17+
Topics:
18+
- "MyDummyTestTopic"
19+
ConsumerGroupId: consumergroup1
20+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Parameters:
3+
StartingPositionValue:
4+
Type: String
5+
Default: LATEST
6+
7+
StreamValue:
8+
Type: String
9+
Default: arn:aws:kafka:us-east-1:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2
10+
11+
TopicsValue:
12+
Type: CommaDelimitedList
13+
Default: Topic
14+
15+
ConsumerGroupValue:
16+
Type: String
17+
Default: consumergroup1
18+
19+
20+
Resources:
21+
MyMskStreamProcessor:
22+
Type: AWS::Serverless::Function
23+
Properties:
24+
Runtime: nodejs12.x
25+
Handler: index.handler
26+
CodeUri: s3://sam-demo-bucket/kafka.zip
27+
Events:
28+
MyMskEvent:
29+
Type: MSK
30+
Properties:
31+
StartingPosition: !Ref StartingPositionValue
32+
Stream: !Ref StreamValue
33+
Topics: !Ref TopicsValue
34+
ConsumerGroupId: !Ref ConsumerGroupValue
35+

tests/translator/input/function_with_self_managed_kafka.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ Resources:
2323
URI: subnet:subnet-12345
2424
- Type: VPC_SECURITY_GROUP
2525
URI: security_group:sg-67890
26+
ConsumerGroupId: consumergroup1
2627

tests/translator/input/self_managed_kafka_with_intrinsics.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,12 @@ Parameters:
1414
KafkaBootstrapServersValue:
1515
Type: CommaDelimitedList
1616
Default: abc.xyz.com:9092,123.45.67.89:9096
17-
18-
17+
18+
ConsumerGroupValue:
19+
Type: String
20+
Default: consumergroup1
21+
22+
1923
Resources:
2024
KafkaFunction:
2125
Type: 'AWS::Serverless::Function'
@@ -43,6 +47,8 @@ Resources:
4347
- Type: BASIC_AUTH
4448
URI:
4549
Ref: KafkaUserSecret
50+
ConsumerGroupId:
51+
Ref: ConsumerGroupValue
4652

4753
KafkaUserSecret:
4854
Type: AWS::SecretsManager::Secret
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Parameters": {},
4+
"Resources": {
5+
"MyMskStreamProcessor": {
6+
"Type": "AWS::Lambda::Function",
7+
"Properties": {
8+
"Code": {
9+
"S3Bucket": "sam-demo-bucket",
10+
"S3Key": "kafka.zip"
11+
},
12+
"Handler": "index.handler",
13+
"Role": {
14+
"Fn::GetAtt": [
15+
"MyMskStreamProcessorRole",
16+
"Arn"
17+
]
18+
},
19+
"Runtime": "nodejs12.x",
20+
"Tags": [
21+
{
22+
"Key": "lambda:createdBy",
23+
"Value": "SAM"
24+
}
25+
]
26+
}
27+
},
28+
"MyMskStreamProcessorRole": {
29+
"Type": "AWS::IAM::Role",
30+
"Properties": {
31+
"AssumeRolePolicyDocument": {
32+
"Version": "2012-10-17",
33+
"Statement": [
34+
{
35+
"Action": [
36+
"sts:AssumeRole"
37+
],
38+
"Effect": "Allow",
39+
"Principal": {
40+
"Service": [
41+
"lambda.amazonaws.com"
42+
]
43+
}
44+
}
45+
]
46+
},
47+
"ManagedPolicyArns": [
48+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
49+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole"
50+
],
51+
"Tags": [
52+
{
53+
"Key": "lambda:createdBy",
54+
"Value": "SAM"
55+
}
56+
]
57+
}
58+
},
59+
"MyMskStreamProcessorMyMskEvent": {
60+
"Type": "AWS::Lambda::EventSourceMapping",
61+
"Properties": {
62+
"EventSourceArn": {
63+
"Fn::Sub": "arn:aws:kafka:${AWS::Region}:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2"
64+
},
65+
"FunctionName": {
66+
"Ref": "MyMskStreamProcessor"
67+
},
68+
"StartingPosition": "LATEST",
69+
"Topics": [
70+
"MyDummyTestTopic"
71+
],
72+
"AmazonManagedKafkaConfig": {
73+
"ConsumerGroupId": "consumergroup1"
74+
}
75+
}
76+
}
77+
}
78+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Parameters": {
4+
"StartingPositionValue": {
5+
"Type": "String",
6+
"Default": "LATEST"
7+
},
8+
"StreamValue": {
9+
"Type": "String",
10+
"Default": "arn:aws:kafka:us-east-1:012345678901:cluster/mycluster/6cc0432b-8618-4f44-bccc-e1fbd8fb7c4d-2"
11+
},
12+
"TopicsValue": {
13+
"Type": "CommaDelimitedList",
14+
"Default": "Topic"
15+
},
16+
"ConsumerGroupValue": {
17+
"Type": "String",
18+
"Default": "consumergroup1"
19+
}
20+
},
21+
"Resources": {
22+
"MyMskStreamProcessor": {
23+
"Type": "AWS::Lambda::Function",
24+
"Properties": {
25+
"Code": {
26+
"S3Bucket": "sam-demo-bucket",
27+
"S3Key": "kafka.zip"
28+
},
29+
"Handler": "index.handler",
30+
"Role": {
31+
"Fn::GetAtt": [
32+
"MyMskStreamProcessorRole",
33+
"Arn"
34+
]
35+
},
36+
"Runtime": "nodejs12.x",
37+
"Tags": [
38+
{
39+
"Key": "lambda:createdBy",
40+
"Value": "SAM"
41+
}
42+
]
43+
}
44+
},
45+
"MyMskStreamProcessorRole": {
46+
"Type": "AWS::IAM::Role",
47+
"Properties": {
48+
"AssumeRolePolicyDocument": {
49+
"Version": "2012-10-17",
50+
"Statement": [
51+
{
52+
"Action": [
53+
"sts:AssumeRole"
54+
],
55+
"Effect": "Allow",
56+
"Principal": {
57+
"Service": [
58+
"lambda.amazonaws.com"
59+
]
60+
}
61+
}
62+
]
63+
},
64+
"ManagedPolicyArns": [
65+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
66+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaMSKExecutionRole"
67+
],
68+
"Tags": [
69+
{
70+
"Key": "lambda:createdBy",
71+
"Value": "SAM"
72+
}
73+
]
74+
}
75+
},
76+
"MyMskStreamProcessorMyMskEvent": {
77+
"Type": "AWS::Lambda::EventSourceMapping",
78+
"Properties": {
79+
"EventSourceArn": {
80+
"Ref": "StreamValue"
81+
},
82+
"FunctionName": {
83+
"Ref": "MyMskStreamProcessor"
84+
},
85+
"StartingPosition": {
86+
"Ref": "StartingPositionValue"
87+
},
88+
"Topics": {
89+
"Ref": "TopicsValue"
90+
},
91+
"AmazonManagedKafkaConfig": {
92+
"ConsumerGroupId": {
93+
"Ref": "ConsumerGroupValue"
94+
}
95+
}
96+
}
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)