Skip to content

Commit 6acdf98

Browse files
authored
Merge branch 'main' into merge-back/2.61.0
2 parents 34f4926 + 42ef507 commit 6acdf98

25 files changed

+1140
-2
lines changed

packages/@aws-cdk/aws-lambda-event-sources/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ behavior:
5757
duration. The default value is 20 seconds.
5858
* __batchSize__: Determines how many records are buffered before invoking your lambda function.
5959
* __maxBatchingWindow__: The maximum amount of time to gather records before invoking the lambda. This increases the likelihood of a full batch at the cost of delayed processing.
60+
* __maxConcurrency__: The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke.
6061
* __enabled__: If the SQS event source mapping should be enabled. The default is true.
6162

6263
```ts

packages/@aws-cdk/aws-lambda-event-sources/lib/sqs.ts

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ export interface SqsEventSourceProps {
4646
* @default - None
4747
*/
4848
readonly filters?: Array<{[key: string]: any}>;
49+
50+
/**
51+
* The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke.
52+
*
53+
* @see https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency
54+
*
55+
* Valid Range: Minimum value of 2. Maximum value of 1000.
56+
*
57+
* @default - No specific limit.
58+
*/
59+
readonly maxConcurrency?: number;
4960
}
5061

5162
/**
@@ -77,6 +88,7 @@ export class SqsEventSource implements lambda.IEventSource {
7788
const eventSourceMapping = target.addEventSourceMapping(`SqsEventSource:${Names.nodeUniqueId(this.queue.node)}`, {
7889
batchSize: this.props.batchSize,
7990
maxBatchingWindow: this.props.maxBatchingWindow,
91+
maxConcurrency: this.props.maxConcurrency,
8092
reportBatchItemFailures: this.props.reportBatchItemFailures,
8193
enabled: this.props.enabled,
8294
eventSourceArn: this.queue.queueArn,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"29.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "29.0.0",
3+
"testCases": {
4+
"integ.sqs-max-concurrency": {
5+
"stacks": [
6+
"sqs-event-source-max-concurrency"
7+
],
8+
"diffAssets": false,
9+
"stackUpdateWorkflow": true
10+
}
11+
},
12+
"synthContext": {},
13+
"enableLookups": false
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"version": "29.0.0",
3+
"artifacts": {
4+
"sqs-event-source-max-concurrency.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "sqs-event-source-max-concurrency.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"sqs-event-source-max-concurrency": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "sqs-event-source-max-concurrency.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/22b851e42ed8369bcaa049b397df6ff215217b6578ec72217a555682af809f17.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"sqs-event-source-max-concurrency.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"sqs-event-source-max-concurrency.assets"
34+
],
35+
"metadata": {
36+
"/sqs-event-source-max-concurrency/F/ServiceRole/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "FServiceRole3AC82EE1"
40+
}
41+
],
42+
"/sqs-event-source-max-concurrency/F/ServiceRole/DefaultPolicy/Resource": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "FServiceRoleDefaultPolicy17A19BFA"
46+
}
47+
],
48+
"/sqs-event-source-max-concurrency/F/Resource": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "FC4345940"
52+
}
53+
],
54+
"/sqs-event-source-max-concurrency/F/SqsEventSource:sqseventsourcemaxconcurrencyQ1268C091/Resource": [
55+
{
56+
"type": "aws:cdk:logicalId",
57+
"data": "FSqsEventSourcesqseventsourcemaxconcurrencyQ1268C091130BF341"
58+
}
59+
],
60+
"/sqs-event-source-max-concurrency/Q/Resource": [
61+
{
62+
"type": "aws:cdk:logicalId",
63+
"data": "Q63C6E3AB"
64+
}
65+
],
66+
"/sqs-event-source-max-concurrency/BootstrapVersion": [
67+
{
68+
"type": "aws:cdk:logicalId",
69+
"data": "BootstrapVersion"
70+
}
71+
],
72+
"/sqs-event-source-max-concurrency/CheckBootstrapVersion": [
73+
{
74+
"type": "aws:cdk:logicalId",
75+
"data": "CheckBootstrapVersion"
76+
}
77+
]
78+
},
79+
"displayName": "sqs-event-source-max-concurrency"
80+
},
81+
"Tree": {
82+
"type": "cdk:tree",
83+
"properties": {
84+
"file": "tree.json"
85+
}
86+
}
87+
}
88+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "29.0.0",
3+
"files": {
4+
"22b851e42ed8369bcaa049b397df6ff215217b6578ec72217a555682af809f17": {
5+
"source": {
6+
"path": "sqs-event-source-max-concurrency.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "22b851e42ed8369bcaa049b397df6ff215217b6578ec72217a555682af809f17.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
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": [
41+
"sqs:ChangeMessageVisibility",
42+
"sqs:DeleteMessage",
43+
"sqs:GetQueueAttributes",
44+
"sqs:GetQueueUrl",
45+
"sqs:ReceiveMessage"
46+
],
47+
"Effect": "Allow",
48+
"Resource": {
49+
"Fn::GetAtt": [
50+
"Q63C6E3AB",
51+
"Arn"
52+
]
53+
}
54+
}
55+
],
56+
"Version": "2012-10-17"
57+
},
58+
"PolicyName": "FServiceRoleDefaultPolicy17A19BFA",
59+
"Roles": [
60+
{
61+
"Ref": "FServiceRole3AC82EE1"
62+
}
63+
]
64+
}
65+
},
66+
"FC4345940": {
67+
"Type": "AWS::Lambda::Function",
68+
"Properties": {
69+
"Code": {
70+
"ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}"
71+
},
72+
"Role": {
73+
"Fn::GetAtt": [
74+
"FServiceRole3AC82EE1",
75+
"Arn"
76+
]
77+
},
78+
"Handler": "index.handler",
79+
"Runtime": "nodejs14.x"
80+
},
81+
"DependsOn": [
82+
"FServiceRoleDefaultPolicy17A19BFA",
83+
"FServiceRole3AC82EE1"
84+
]
85+
},
86+
"FSqsEventSourcesqseventsourcemaxconcurrencyQ1268C091130BF341": {
87+
"Type": "AWS::Lambda::EventSourceMapping",
88+
"Properties": {
89+
"FunctionName": {
90+
"Ref": "FC4345940"
91+
},
92+
"BatchSize": 5,
93+
"EventSourceArn": {
94+
"Fn::GetAtt": [
95+
"Q63C6E3AB",
96+
"Arn"
97+
]
98+
},
99+
"ScalingConfig": {
100+
"MaximumConcurrency": 5
101+
}
102+
}
103+
},
104+
"Q63C6E3AB": {
105+
"Type": "AWS::SQS::Queue",
106+
"UpdateReplacePolicy": "Delete",
107+
"DeletionPolicy": "Delete"
108+
}
109+
},
110+
"Parameters": {
111+
"BootstrapVersion": {
112+
"Type": "AWS::SSM::Parameter::Value<String>",
113+
"Default": "/cdk-bootstrap/hnb659fds/version",
114+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
115+
}
116+
},
117+
"Rules": {
118+
"CheckBootstrapVersion": {
119+
"Assertions": [
120+
{
121+
"Assert": {
122+
"Fn::Not": [
123+
{
124+
"Fn::Contains": [
125+
[
126+
"1",
127+
"2",
128+
"3",
129+
"4",
130+
"5"
131+
],
132+
{
133+
"Ref": "BootstrapVersion"
134+
}
135+
]
136+
}
137+
]
138+
},
139+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
140+
}
141+
]
142+
}
143+
}
144+
}

0 commit comments

Comments
 (0)