Skip to content

Commit ed8852f

Browse files
committed
feat: Support SQS Maximum Concurrency
1 parent 6c83ab6 commit ed8852f

File tree

8 files changed

+240
-0
lines changed

8 files changed

+240
-0
lines changed

samtranslator/model/eventsources/pull.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class PullEventSource(ResourceMacro):
5555
"KafkaBootstrapServers": PropertyType(False, is_type(list)),
5656
"FilterCriteria": PropertyType(False, is_type(dict)),
5757
"ConsumerGroupId": PropertyType(False, is_str()),
58+
"ScalingConfig": PropertyType(False, is_type(dict)),
5859
}
5960

6061
Stream: Optional[Intrinsicable[str]]
@@ -78,6 +79,7 @@ class PullEventSource(ResourceMacro):
7879
KafkaBootstrapServers: Optional[List[Any]]
7980
FilterCriteria: Optional[Dict[str, Any]]
8081
ConsumerGroupId: Optional[Intrinsicable[str]]
82+
ScalingConfig: Optional[Dict[str, Any]]
8183

8284
def get_policy_arn(self): # type: ignore[no-untyped-def]
8385
raise NotImplementedError("Subclass must implement this method")
@@ -137,6 +139,7 @@ def to_cloudformation(self, **kwargs): # type: ignore[no-untyped-def]
137139
lambda_eventsourcemapping.TumblingWindowInSeconds = self.TumblingWindowInSeconds
138140
lambda_eventsourcemapping.FunctionResponseTypes = self.FunctionResponseTypes
139141
lambda_eventsourcemapping.FilterCriteria = self.FilterCriteria
142+
lambda_eventsourcemapping.ScalingConfig = self.ScalingConfig
140143
self._validate_filter_criteria() # type: ignore[no-untyped-call]
141144

142145
if self.KafkaBootstrapServers:

samtranslator/model/lambda_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class LambdaEventSourceMapping(Resource):
8484
"FilterCriteria": PropertyType(False, is_type(dict)),
8585
"AmazonManagedKafkaEventSourceConfig": PropertyType(False, is_type(dict)),
8686
"SelfManagedKafkaEventSourceConfig": PropertyType(False, is_type(dict)),
87+
"ScalingConfig": PropertyType(False, is_type(dict)),
8788
}
8889

8990
runtime_attrs = {"name": lambda self: ref(self.logical_id)}

samtranslator/schema/aws_serverless_function.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ class SQSEventProperties(BaseModel):
193193
FilterCriteria: Optional[PassThrough] = sqseventproperties("FilterCriteria")
194194
MaximumBatchingWindowInSeconds: Optional[PassThrough] = sqseventproperties("MaximumBatchingWindowInSeconds")
195195
Queue: PassThrough = sqseventproperties("Queue")
196+
ScalingConfig: Optional[PassThrough] # Update docs when live
196197

197198

198199
class SQSEvent(BaseModel):

samtranslator/schema/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,9 @@
22912291
"title": "Queue",
22922292
"description": "The ARN of the queue\\. \n*Type*: String \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`EventSourceArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn) property of an `AWS::Lambda::EventSourceMapping` resource\\.",
22932293
"markdownDescription": "The ARN of the queue\\. \n*Type*: String \n*Required*: Yes \n*AWS CloudFormation compatibility*: This property is passed directly to the [`EventSourceArn`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-eventsourcearn) property of an `AWS::Lambda::EventSourceMapping` resource\\."
2294+
},
2295+
"ScalingConfig": {
2296+
"title": "Scalingconfig"
22942297
}
22952298
},
22962299
"additionalProperties": false
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Resources:
2+
SQSFunction:
3+
Type: AWS::Serverless::Function
4+
Properties:
5+
CodeUri: s3://sam-demo-bucket/queues.zip
6+
Handler: queue.sqs_handler
7+
Runtime: python2.7
8+
Events:
9+
MySqsQueue:
10+
Type: SQS
11+
Properties:
12+
Queue: arn:aws:sqs:us-west-2:012345678901:my-queue
13+
BatchSize: 10
14+
Enabled: false
15+
ScalingConfig:
16+
MaximumConcurrency: 500
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Resources": {
3+
"SQSFunction": {
4+
"Properties": {
5+
"Code": {
6+
"S3Bucket": "sam-demo-bucket",
7+
"S3Key": "queues.zip"
8+
},
9+
"Handler": "queue.sqs_handler",
10+
"Role": {
11+
"Fn::GetAtt": [
12+
"SQSFunctionRole",
13+
"Arn"
14+
]
15+
},
16+
"Runtime": "python2.7",
17+
"Tags": [
18+
{
19+
"Key": "lambda:createdBy",
20+
"Value": "SAM"
21+
}
22+
]
23+
},
24+
"Type": "AWS::Lambda::Function"
25+
},
26+
"SQSFunctionMySqsQueue": {
27+
"Properties": {
28+
"BatchSize": 10,
29+
"Enabled": false,
30+
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
31+
"FunctionName": {
32+
"Ref": "SQSFunction"
33+
},
34+
"ScalingConfig": {
35+
"MaximumConcurrency": 500
36+
}
37+
},
38+
"Type": "AWS::Lambda::EventSourceMapping"
39+
},
40+
"SQSFunctionRole": {
41+
"Properties": {
42+
"AssumeRolePolicyDocument": {
43+
"Statement": [
44+
{
45+
"Action": [
46+
"sts:AssumeRole"
47+
],
48+
"Effect": "Allow",
49+
"Principal": {
50+
"Service": [
51+
"lambda.amazonaws.com"
52+
]
53+
}
54+
}
55+
],
56+
"Version": "2012-10-17"
57+
},
58+
"ManagedPolicyArns": [
59+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
60+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
}
71+
}
72+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Resources": {
3+
"SQSFunction": {
4+
"Properties": {
5+
"Code": {
6+
"S3Bucket": "sam-demo-bucket",
7+
"S3Key": "queues.zip"
8+
},
9+
"Handler": "queue.sqs_handler",
10+
"Role": {
11+
"Fn::GetAtt": [
12+
"SQSFunctionRole",
13+
"Arn"
14+
]
15+
},
16+
"Runtime": "python2.7",
17+
"Tags": [
18+
{
19+
"Key": "lambda:createdBy",
20+
"Value": "SAM"
21+
}
22+
]
23+
},
24+
"Type": "AWS::Lambda::Function"
25+
},
26+
"SQSFunctionMySqsQueue": {
27+
"Properties": {
28+
"BatchSize": 10,
29+
"Enabled": false,
30+
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
31+
"FunctionName": {
32+
"Ref": "SQSFunction"
33+
},
34+
"ScalingConfig": {
35+
"MaximumConcurrency": 500
36+
}
37+
},
38+
"Type": "AWS::Lambda::EventSourceMapping"
39+
},
40+
"SQSFunctionRole": {
41+
"Properties": {
42+
"AssumeRolePolicyDocument": {
43+
"Statement": [
44+
{
45+
"Action": [
46+
"sts:AssumeRole"
47+
],
48+
"Effect": "Allow",
49+
"Principal": {
50+
"Service": [
51+
"lambda.amazonaws.com"
52+
]
53+
}
54+
}
55+
],
56+
"Version": "2012-10-17"
57+
},
58+
"ManagedPolicyArns": [
59+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
60+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
}
71+
}
72+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"Resources": {
3+
"SQSFunction": {
4+
"Properties": {
5+
"Code": {
6+
"S3Bucket": "sam-demo-bucket",
7+
"S3Key": "queues.zip"
8+
},
9+
"Handler": "queue.sqs_handler",
10+
"Role": {
11+
"Fn::GetAtt": [
12+
"SQSFunctionRole",
13+
"Arn"
14+
]
15+
},
16+
"Runtime": "python2.7",
17+
"Tags": [
18+
{
19+
"Key": "lambda:createdBy",
20+
"Value": "SAM"
21+
}
22+
]
23+
},
24+
"Type": "AWS::Lambda::Function"
25+
},
26+
"SQSFunctionMySqsQueue": {
27+
"Properties": {
28+
"BatchSize": 10,
29+
"Enabled": false,
30+
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
31+
"FunctionName": {
32+
"Ref": "SQSFunction"
33+
},
34+
"ScalingConfig": {
35+
"MaximumConcurrency": 500
36+
}
37+
},
38+
"Type": "AWS::Lambda::EventSourceMapping"
39+
},
40+
"SQSFunctionRole": {
41+
"Properties": {
42+
"AssumeRolePolicyDocument": {
43+
"Statement": [
44+
{
45+
"Action": [
46+
"sts:AssumeRole"
47+
],
48+
"Effect": "Allow",
49+
"Principal": {
50+
"Service": [
51+
"lambda.amazonaws.com"
52+
]
53+
}
54+
}
55+
],
56+
"Version": "2012-10-17"
57+
},
58+
"ManagedPolicyArns": [
59+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
60+
"arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)