Skip to content

Commit 68b969e

Browse files
authored
feat(lambda): support for Provisioned Pollers (#32205)
### Reason for this change Lambda is introducing a new property in Event Sources named `ProvisionedPollerConfig` to set provisioned pollers that read from the event sources. When specified, it allows control over the minimum and maximum number of pollers that can be provisioned to process events from the source. This feature is currently supported for MSK and Self-managed Kafka event sources. ### Description of changes This new property can be opted in by setting the `ProvisionedPollerConfig` field while creating event sources. The example of setting `ProvisionedPollerConfig` for is shown below: ``` fn.addEventSource(new sources.ManagedKafkaEventSource( { clusterArn, topic: kafkaTopic, startingPosition: lambda.StartingPosition.TRIM_HORIZON, provisionedPollerConfig: { minimumPollers: 1, maximumPollers: 3, }, })) ``` ### Description of how you validated changes Have added unit test and integration test to validate the implementation ### 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 e1195f9 commit 68b969e

15 files changed

+781
-11
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-selfmanaged.js.snapshot/LambdaEventSourceKafkaSelfManagedTestDefaultTestDeployAssertAF78BD0F.assets.json

+1-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.kafka-selfmanaged.js.snapshot/cdk.out

+1-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.kafka-selfmanaged.js.snapshot/integ.json

+1-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.kafka-selfmanaged.js.snapshot/lambda-event-source-kafka-self-managed.assets.json

+3-3
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.kafka-selfmanaged.js.snapshot/lambda-event-source-kafka-self-managed.template.json

+132
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,138 @@
322322
"my-test-topic2"
323323
]
324324
}
325+
},
326+
"F3ServiceRole2F65FFC0": {
327+
"Type": "AWS::IAM::Role",
328+
"Properties": {
329+
"AssumeRolePolicyDocument": {
330+
"Statement": [
331+
{
332+
"Action": "sts:AssumeRole",
333+
"Effect": "Allow",
334+
"Principal": {
335+
"Service": "lambda.amazonaws.com"
336+
}
337+
}
338+
],
339+
"Version": "2012-10-17"
340+
},
341+
"ManagedPolicyArns": [
342+
{
343+
"Fn::Join": [
344+
"",
345+
[
346+
"arn:",
347+
{
348+
"Ref": "AWS::Partition"
349+
},
350+
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
351+
]
352+
]
353+
}
354+
]
355+
}
356+
},
357+
"F3ServiceRoleDefaultPolicy1C0463D1": {
358+
"Type": "AWS::IAM::Policy",
359+
"Properties": {
360+
"PolicyDocument": {
361+
"Statement": [
362+
{
363+
"Action": [
364+
"secretsmanager:DescribeSecret",
365+
"secretsmanager:GetSecretValue"
366+
],
367+
"Effect": "Allow",
368+
"Resource": [
369+
{
370+
"Ref": "S509448A1"
371+
},
372+
{
373+
"Ref": "SC0855C491"
374+
}
375+
]
376+
}
377+
],
378+
"Version": "2012-10-17"
379+
},
380+
"PolicyName": "F3ServiceRoleDefaultPolicy1C0463D1",
381+
"Roles": [
382+
{
383+
"Ref": "F3ServiceRole2F65FFC0"
384+
}
385+
]
386+
}
387+
},
388+
"F38FF9B13A": {
389+
"Type": "AWS::Lambda::Function",
390+
"Properties": {
391+
"Code": {
392+
"ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}"
393+
},
394+
"Handler": "index.handler",
395+
"Role": {
396+
"Fn::GetAtt": [
397+
"F3ServiceRole2F65FFC0",
398+
"Arn"
399+
]
400+
},
401+
"Runtime": "nodejs18.x"
402+
},
403+
"DependsOn": [
404+
"F3ServiceRoleDefaultPolicy1C0463D1",
405+
"F3ServiceRole2F65FFC0"
406+
]
407+
},
408+
"F3KafkaEventSource838c4d5ff3c99c1a617120adfca83e5bmytesttopic3ED015F25": {
409+
"Type": "AWS::Lambda::EventSourceMapping",
410+
"Properties": {
411+
"BatchSize": 100,
412+
"FilterCriteria": {
413+
"Filters": [
414+
{
415+
"Pattern": "{\"numericEquals\":[{\"numeric\":[\"=\",1]}]}"
416+
}
417+
]
418+
},
419+
"FunctionName": {
420+
"Ref": "F38FF9B13A"
421+
},
422+
"ProvisionedPollerConfig": {
423+
"MaximumPollers": 3,
424+
"MinimumPollers": 1
425+
},
426+
"SelfManagedEventSource": {
427+
"Endpoints": {
428+
"KafkaBootstrapServers": [
429+
"my-self-hosted-kafka-broker-1:9092",
430+
"my-self-hosted-kafka-broker-2:9092",
431+
"my-self-hosted-kafka-broker-3:9092"
432+
]
433+
}
434+
},
435+
"SelfManagedKafkaEventSourceConfig": {
436+
"ConsumerGroupId": "myTestConsumerGroup3"
437+
},
438+
"SourceAccessConfigurations": [
439+
{
440+
"Type": "CLIENT_CERTIFICATE_TLS_AUTH",
441+
"URI": {
442+
"Ref": "SC0855C491"
443+
}
444+
},
445+
{
446+
"Type": "SERVER_ROOT_CA_CERTIFICATE",
447+
"URI": {
448+
"Ref": "S509448A1"
449+
}
450+
}
451+
],
452+
"StartingPosition": "TRIM_HORIZON",
453+
"Topics": [
454+
"my-test-topic3"
455+
]
456+
}
325457
}
326458
},
327459
"Parameters": {

packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kafka-selfmanaged.js.snapshot/manifest.json

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

0 commit comments

Comments
 (0)