From dcd88628a1ab206a1526ca1302c0b3086d95ed01 Mon Sep 17 00:00:00 2001 From: Vandita2020 Date: Wed, 13 Nov 2024 21:48:16 -0800 Subject: [PATCH 1/5] support for metrics config --- .../cdk.out | 1 + .../integ.json | 12 + ...source-metrics-config-dynamodb.assets.json | 19 + ...urce-metrics-config-dynamodb.template.json | 276 ++++++++++ ...efaultTestDeployAssertC1C197C4.assets.json | 19 + ...aultTestDeployAssertC1C197C4.template.json | 36 ++ .../manifest.json | 163 ++++++ .../tree.json | 515 ++++++++++++++++++ .../integ.dynamodb-with-metrics-config.ts | 44 ++ .../cdk.out | 1 + .../integ.json | 12 + ...-source-metrics-config-kinesis.assets.json | 19 + ...ource-metrics-config-kinesis.template.json | 295 ++++++++++ ...efaultTestDeployAssert312685CA.assets.json | 19 + ...aultTestDeployAssert312685CA.template.json | 36 ++ .../manifest.json | 169 ++++++ .../tree.json | 512 +++++++++++++++++ .../test/integ.kinesis-with-metrics-config.ts | 36 ++ .../cdk.out | 1 + .../integ.json | 12 + ...vent-source-metrics-config-sqs.assets.json | 19 + ...nt-source-metrics-config-sqs.template.json | 239 ++++++++ ...efaultTestDeployAssert9B567B16.assets.json | 19 + ...aultTestDeployAssert9B567B16.template.json | 36 ++ .../manifest.json | 163 ++++++ .../tree.json | 471 ++++++++++++++++ .../test/integ.sqs-with-metrics-config.ts | 36 ++ .../aws-lambda-event-sources/lib/dynamodb.ts | 5 +- .../aws-lambda-event-sources/lib/kinesis.ts | 1 + .../aws-lambda-event-sources/lib/sqs.ts | 28 + .../aws-lambda-event-sources/lib/stream.ts | 27 + .../test/dynamo.test.ts | 61 +++ .../test/kinesis.test.ts | 47 ++ .../aws-lambda-event-sources/test/sqs.test.ts | 42 ++ packages/aws-cdk-lib/aws-lambda/README.md | 28 + .../aws-lambda/lib/event-source-mapping.ts | 28 + .../test/event-source-mapping.test.ts | 41 ++ packages/aws-cdk-lib/awslint.json | 21 + ...ws-lambda-event-source-metrics-config.json | 512 +++++++++++++++++ 39 files changed, 4020 insertions(+), 1 deletion(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts create mode 100644 tools/@aws-cdk/spec2cdk/temporary-schemas/us-east-1/aws-lambda-event-source-metrics-config.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/integ.json new file mode 100644 index 0000000000000..28ee4cf843b23 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "lambda-event-source-dynamodb-with-metrics/DefaultTest": { + "stacks": [ + "lambda-event-source-metrics-config-dynamodb" + ], + "assertionStack": "lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert", + "assertionStackName": "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.assets.json new file mode 100644 index 0000000000000..c526cc0870668 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "ba285c3d32df9eb5784aa37a7742b096033c91381c3f2ba7d10f22061c8468d7": { + "source": { + "path": "lambda-event-source-metrics-config-dynamodb.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "ba285c3d32df9eb5784aa37a7742b096033c91381c3f2ba7d10f22061c8468d7.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.template.json new file mode 100644 index 0000000000000..85741d80c0c2e --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-dynamodb.template.json @@ -0,0 +1,276 @@ +{ + "Resources": { + "FServiceRole3AC82EE1": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "FServiceRoleDefaultPolicy17A19BFA": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "dynamodb:ListStreams", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "dynamodb:DescribeStream", + "dynamodb:GetRecords", + "dynamodb:GetShardIterator" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "FServiceRoleDefaultPolicy17A19BFA", + "Roles": [ + { + "Ref": "FServiceRole3AC82EE1" + } + ] + } + }, + "FC4345940": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "FServiceRole3AC82EE1", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "FServiceRoleDefaultPolicy17A19BFA", + "FServiceRole3AC82EE1" + ] + }, + "FDynamoDBEventSourcelambdaeventsourcemetricsconfigdynamodbT8ABCAB8CB3F48FC4": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 5, + "EventSourceArn": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + }, + "FunctionName": { + "Ref": "FC4345940" + }, + "MetricsConfig": { + "Metrics": [] + }, + "StartingPosition": "LATEST" + } + }, + "TD925BC7E": { + "Type": "AWS::DynamoDB::Table", + "Properties": { + "AttributeDefinitions": [ + { + "AttributeName": "id", + "AttributeType": "S" + } + ], + "KeySchema": [ + { + "AttributeName": "id", + "KeyType": "HASH" + } + ], + "ProvisionedThroughput": { + "ReadCapacityUnits": 5, + "WriteCapacityUnits": 5 + }, + "StreamSpecification": { + "StreamViewType": "NEW_IMAGE" + } + }, + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "F5ServiceRole2E897519": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "F5ServiceRoleDefaultPolicyF3745DE6": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": "dynamodb:ListStreams", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "dynamodb:DescribeStream", + "dynamodb:GetRecords", + "dynamodb:GetShardIterator" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "F5ServiceRoleDefaultPolicyF3745DE6", + "Roles": [ + { + "Ref": "F5ServiceRole2E897519" + } + ] + } + }, + "F5B560B5F9": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "F5ServiceRole2E897519", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "F5ServiceRoleDefaultPolicyF3745DE6", + "F5ServiceRole2E897519" + ] + }, + "F5DynamoDBEventSourcelambdaeventsourcemetricsconfigdynamodbT8ABCAB8CD0816D3E": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 5, + "EventSourceArn": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + }, + "FunctionName": { + "Ref": "F5B560B5F9" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount" + ] + }, + "StartingPosition": "LATEST" + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets.json new file mode 100644 index 0000000000000..cc7fbe2fa9036 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/manifest.json new file mode 100644 index 0000000000000..b79edc4146de6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/manifest.json @@ -0,0 +1,163 @@ +{ + "version": "38.0.1", + "artifacts": { + "lambda-event-source-metrics-config-dynamodb.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambda-event-source-metrics-config-dynamodb.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambda-event-source-metrics-config-dynamodb": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambda-event-source-metrics-config-dynamodb.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/ba285c3d32df9eb5784aa37a7742b096033c91381c3f2ba7d10f22061c8468d7.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambda-event-source-metrics-config-dynamodb.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambda-event-source-metrics-config-dynamodb.assets" + ], + "metadata": { + "/lambda-event-source-metrics-config-dynamodb/F/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FServiceRole3AC82EE1" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FServiceRoleDefaultPolicy17A19BFA" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FC4345940" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FDynamoDBEventSourcelambdaeventsourcemetricsconfigdynamodbT8ABCAB8CB3F48FC4" + } + ], + "/lambda-event-source-metrics-config-dynamodb/T/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "TD925BC7E" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F5ServiceRole2E897519" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F5ServiceRoleDefaultPolicyF3745DE6" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F5/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F5B560B5F9" + } + ], + "/lambda-event-source-metrics-config-dynamodb/F5/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F5DynamoDBEventSourcelambdaeventsourcemetricsconfigdynamodbT8ABCAB8CD0816D3E" + } + ], + "/lambda-event-source-metrics-config-dynamodb/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-metrics-config-dynamodb/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-metrics-config-dynamodb" + }, + "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambdaeventsourcedynamodbwithmetricsDefaultTestDeployAssertC1C197C4.assets" + ], + "metadata": { + "/lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/tree.json new file mode 100644 index 0000000000000..a45727d05112b --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.js.snapshot/tree.json @@ -0,0 +1,515 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "lambda-event-source-metrics-config-dynamodb": { + "id": "lambda-event-source-metrics-config-dynamodb", + "path": "lambda-event-source-metrics-config-dynamodb", + "children": { + "F": { + "id": "F", + "path": "lambda-event-source-metrics-config-dynamodb/F", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-dynamodb/F/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-dynamodb/F/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-dynamodb/F/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "dynamodb:ListStreams", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "dynamodb:DescribeStream", + "dynamodb:GetRecords", + "dynamodb:GetShardIterator" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "FServiceRoleDefaultPolicy17A19BFA", + "roles": [ + { + "Ref": "FServiceRole3AC82EE1" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "FServiceRole3AC82EE1", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C": { + "id": "DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C", + "path": "lambda-event-source-metrics-config-dynamodb/F/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 5, + "eventSourceArn": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + }, + "functionName": { + "Ref": "FC4345940" + }, + "metricsConfig": { + "metrics": [] + }, + "startingPosition": "LATEST" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "T": { + "id": "T", + "path": "lambda-event-source-metrics-config-dynamodb/T", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/T/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::DynamoDB::Table", + "aws:cdk:cloudformation:props": { + "attributeDefinitions": [ + { + "attributeName": "id", + "attributeType": "S" + } + ], + "keySchema": [ + { + "attributeName": "id", + "keyType": "HASH" + } + ], + "provisionedThroughput": { + "readCapacityUnits": 5, + "writeCapacityUnits": 5 + }, + "streamSpecification": { + "streamViewType": "NEW_IMAGE" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_dynamodb.CfnTable", + "version": "0.0.0" + } + }, + "ScalingRole": { + "id": "ScalingRole", + "path": "lambda-event-source-metrics-config-dynamodb/T/ScalingRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_dynamodb.Table", + "version": "0.0.0" + } + }, + "F5": { + "id": "F5", + "path": "lambda-event-source-metrics-config-dynamodb/F5", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-dynamodb/F5/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F5/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": "dynamodb:ListStreams", + "Effect": "Allow", + "Resource": "*" + }, + { + "Action": [ + "dynamodb:DescribeStream", + "dynamodb:GetRecords", + "dynamodb:GetShardIterator" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "F5ServiceRoleDefaultPolicyF3745DE6", + "roles": [ + { + "Ref": "F5ServiceRole2E897519" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F5/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "F5ServiceRole2E897519", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C": { + "id": "DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C", + "path": "lambda-event-source-metrics-config-dynamodb/F5/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-dynamodb/F5/DynamoDBEventSource:lambdaeventsourcemetricsconfigdynamodbT8ABCAB8C/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 5, + "eventSourceArn": { + "Fn::GetAtt": [ + "TD925BC7E", + "StreamArn" + ] + }, + "functionName": { + "Ref": "F5B560B5F9" + }, + "metricsConfig": { + "metrics": [ + "EventCount" + ] + }, + "startingPosition": "LATEST" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-metrics-config-dynamodb/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-metrics-config-dynamodb/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "lambda-event-source-dynamodb-with-metrics": { + "id": "lambda-event-source-dynamodb-with-metrics", + "path": "lambda-event-source-dynamodb-with-metrics", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "lambda-event-source-dynamodb-with-metrics/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "lambda-event-source-dynamodb-with-metrics/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-dynamodb-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts new file mode 100644 index 0000000000000..6b393ca7e5390 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts @@ -0,0 +1,44 @@ +import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; +import * as lambda from 'aws-cdk-lib/aws-lambda'; +import * as cdk from 'aws-cdk-lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import { TestFunction } from './test-function'; +import { DynamoEventSource, MetricType } from 'aws-cdk-lib/aws-lambda-event-sources'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'lambda-event-source-metrics-config-dynamodb'); + +const fn = new TestFunction(stack, 'F'); +const table = new dynamodb.Table(stack, 'T', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + stream: dynamodb.StreamViewType.NEW_IMAGE, + removalPolicy: cdk.RemovalPolicy.DESTROY, +}); + +fn.addEventSource(new DynamoEventSource(table, { + batchSize: 5, + startingPosition: lambda.StartingPosition.LATEST, + metricsConfig: { + metrics: [], + }, +})); + +const fn2 = new TestFunction(stack, 'F5'); + +fn2.addEventSource(new DynamoEventSource(table, { + batchSize: 5, + startingPosition: lambda.StartingPosition.LATEST, + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + }, +})); + +new integ.IntegTest(app, 'lambda-event-source-dynamodb-with-metrics', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/integ.json new file mode 100644 index 0000000000000..ac171bdaf896f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "lambda-event-source-kinesis-with-metrics/DefaultTest": { + "stacks": [ + "lambda-event-source-metrics-config-kinesis" + ], + "assertionStack": "lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert", + "assertionStackName": "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.assets.json new file mode 100644 index 0000000000000..40991e6605340 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "9120ee36b9682319f9ed5de63284660b20f3b32efa59df7674ce97b8499f19ec": { + "source": { + "path": "lambda-event-source-metrics-config-kinesis.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "9120ee36b9682319f9ed5de63284660b20f3b32efa59df7674ce97b8499f19ec.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.template.json new file mode 100644 index 0000000000000..df6780751b64d --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-kinesis.template.json @@ -0,0 +1,295 @@ +{ + "Resources": { + "F1ServiceRoleCCF1273A": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "F1ServiceRoleDefaultPolicy1610A985": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:DescribeStreamConsumer", + "kinesis:DescribeStreamSummary", + "kinesis:GetRecords", + "kinesis:GetShardIterator", + "kinesis:ListShards", + "kinesis:ListStreams", + "kinesis:SubscribeToShard" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "F1ServiceRoleDefaultPolicy1610A985", + "Roles": [ + { + "Ref": "F1ServiceRoleCCF1273A" + } + ] + } + }, + "F1EAD92DBE": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "F1ServiceRoleCCF1273A", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "F1ServiceRoleDefaultPolicy1610A985", + "F1ServiceRoleCCF1273A" + ] + }, + "F1KinesisEventSourcelambdaeventsourcemetricsconfigkinesisQC556E77A18ED795E": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 100, + "EventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "FunctionName": { + "Ref": "F1EAD92DBE" + }, + "MetricsConfig": { + "Metrics": [] + }, + "StartingPosition": "TRIM_HORIZON", + "TumblingWindowInSeconds": 60 + } + }, + "Q63C6E3AB": { + "Type": "AWS::Kinesis::Stream", + "Properties": { + "RetentionPeriodHours": 24, + "ShardCount": 1, + "StreamEncryption": { + "Fn::If": [ + "AwsCdkKinesisEncryptedStreamsUnsupportedRegions", + { + "Ref": "AWS::NoValue" + }, + { + "EncryptionType": "KMS", + "KeyId": "alias/aws/kinesis" + } + ] + } + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "F2ServiceRole7F7C6006": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "F2ServiceRoleDefaultPolicy999D30A8": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:DescribeStreamConsumer", + "kinesis:DescribeStreamSummary", + "kinesis:GetRecords", + "kinesis:GetShardIterator", + "kinesis:ListShards", + "kinesis:ListStreams", + "kinesis:SubscribeToShard" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "F2ServiceRoleDefaultPolicy999D30A8", + "Roles": [ + { + "Ref": "F2ServiceRole7F7C6006" + } + ] + } + }, + "F23BAC7B9C": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "F2ServiceRole7F7C6006", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "F2ServiceRoleDefaultPolicy999D30A8", + "F2ServiceRole7F7C6006" + ] + }, + "F2KinesisEventSourcelambdaeventsourcemetricsconfigkinesisQC556E77AF07F466E": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 100, + "EventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "FunctionName": { + "Ref": "F23BAC7B9C" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount" + ] + }, + "StartingPosition": "TRIM_HORIZON", + "TumblingWindowInSeconds": 60 + } + } + }, + "Conditions": { + "AwsCdkKinesisEncryptedStreamsUnsupportedRegions": { + "Fn::Or": [ + { + "Fn::Equals": [ + { + "Ref": "AWS::Region" + }, + "cn-north-1" + ] + }, + { + "Fn::Equals": [ + { + "Ref": "AWS::Region" + }, + "cn-northwest-1" + ] + } + ] + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets.json new file mode 100644 index 0000000000000..800102a5ccacc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/manifest.json new file mode 100644 index 0000000000000..4f13cc0d62bb7 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/manifest.json @@ -0,0 +1,169 @@ +{ + "version": "38.0.1", + "artifacts": { + "lambda-event-source-metrics-config-kinesis.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambda-event-source-metrics-config-kinesis.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambda-event-source-metrics-config-kinesis": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambda-event-source-metrics-config-kinesis.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/9120ee36b9682319f9ed5de63284660b20f3b32efa59df7674ce97b8499f19ec.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambda-event-source-metrics-config-kinesis.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambda-event-source-metrics-config-kinesis.assets" + ], + "metadata": { + "/lambda-event-source-metrics-config-kinesis/F1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1ServiceRoleCCF1273A" + } + ], + "/lambda-event-source-metrics-config-kinesis/F1/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1ServiceRoleDefaultPolicy1610A985" + } + ], + "/lambda-event-source-metrics-config-kinesis/F1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1EAD92DBE" + } + ], + "/lambda-event-source-metrics-config-kinesis/F1/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1KinesisEventSourcelambdaeventsourcemetricsconfigkinesisQC556E77A18ED795E" + } + ], + "/lambda-event-source-metrics-config-kinesis/Q/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Q63C6E3AB" + } + ], + "/lambda-event-source-metrics-config-kinesis/AwsCdkKinesisEncryptedStreamsUnsupportedRegions": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsCdkKinesisEncryptedStreamsUnsupportedRegions" + } + ], + "/lambda-event-source-metrics-config-kinesis/F2/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2ServiceRole7F7C6006" + } + ], + "/lambda-event-source-metrics-config-kinesis/F2/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2ServiceRoleDefaultPolicy999D30A8" + } + ], + "/lambda-event-source-metrics-config-kinesis/F2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F23BAC7B9C" + } + ], + "/lambda-event-source-metrics-config-kinesis/F2/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2KinesisEventSourcelambdaeventsourcemetricsconfigkinesisQC556E77AF07F466E" + } + ], + "/lambda-event-source-metrics-config-kinesis/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-metrics-config-kinesis/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-metrics-config-kinesis" + }, + "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambdaeventsourcekinesiswithmetricsDefaultTestDeployAssert312685CA.assets" + ], + "metadata": { + "/lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/tree.json new file mode 100644 index 0000000000000..8a06743fd1d47 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.js.snapshot/tree.json @@ -0,0 +1,512 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "lambda-event-source-metrics-config-kinesis": { + "id": "lambda-event-source-metrics-config-kinesis", + "path": "lambda-event-source-metrics-config-kinesis", + "children": { + "F1": { + "id": "F1", + "path": "lambda-event-source-metrics-config-kinesis/F1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-kinesis/F1/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-kinesis/F1/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-kinesis/F1/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F1/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:DescribeStreamConsumer", + "kinesis:DescribeStreamSummary", + "kinesis:GetRecords", + "kinesis:GetShardIterator", + "kinesis:ListShards", + "kinesis:ListStreams", + "kinesis:SubscribeToShard" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "F1ServiceRoleDefaultPolicy1610A985", + "roles": [ + { + "Ref": "F1ServiceRoleCCF1273A" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "F1ServiceRoleCCF1273A", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A": { + "id": "KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A", + "path": "lambda-event-source-metrics-config-kinesis/F1/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F1/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 100, + "eventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "functionName": { + "Ref": "F1EAD92DBE" + }, + "metricsConfig": { + "metrics": [] + }, + "startingPosition": "TRIM_HORIZON", + "tumblingWindowInSeconds": 60 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "Q": { + "id": "Q", + "path": "lambda-event-source-metrics-config-kinesis/Q", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/Q/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Kinesis::Stream", + "aws:cdk:cloudformation:props": { + "retentionPeriodHours": 24, + "shardCount": 1, + "streamEncryption": { + "Fn::If": [ + "AwsCdkKinesisEncryptedStreamsUnsupportedRegions", + { + "Ref": "AWS::NoValue" + }, + { + "EncryptionType": "KMS", + "KeyId": "alias/aws/kinesis" + } + ] + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_kinesis.CfnStream", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_kinesis.Stream", + "version": "0.0.0" + } + }, + "AwsCdkKinesisEncryptedStreamsUnsupportedRegions": { + "id": "AwsCdkKinesisEncryptedStreamsUnsupportedRegions", + "path": "lambda-event-source-metrics-config-kinesis/AwsCdkKinesisEncryptedStreamsUnsupportedRegions", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnCondition", + "version": "0.0.0" + } + }, + "F2": { + "id": "F2", + "path": "lambda-event-source-metrics-config-kinesis/F2", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-kinesis/F2/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-kinesis/F2/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F2/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-kinesis/F2/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F2/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "kinesis:DescribeStream", + "kinesis:DescribeStreamConsumer", + "kinesis:DescribeStreamSummary", + "kinesis:GetRecords", + "kinesis:GetShardIterator", + "kinesis:ListShards", + "kinesis:ListStreams", + "kinesis:SubscribeToShard" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "F2ServiceRoleDefaultPolicy999D30A8", + "roles": [ + { + "Ref": "F2ServiceRole7F7C6006" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "F2ServiceRole7F7C6006", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A": { + "id": "KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A", + "path": "lambda-event-source-metrics-config-kinesis/F2/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-kinesis/F2/KinesisEventSource:lambdaeventsourcemetricsconfigkinesisQC556E77A/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 100, + "eventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "functionName": { + "Ref": "F23BAC7B9C" + }, + "metricsConfig": { + "metrics": [ + "EventCount" + ] + }, + "startingPosition": "TRIM_HORIZON", + "tumblingWindowInSeconds": 60 + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-metrics-config-kinesis/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-metrics-config-kinesis/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "lambda-event-source-kinesis-with-metrics": { + "id": "lambda-event-source-kinesis-with-metrics", + "path": "lambda-event-source-kinesis-with-metrics", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "lambda-event-source-kinesis-with-metrics/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "lambda-event-source-kinesis-with-metrics/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-kinesis-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts new file mode 100644 index 0000000000000..881d00b855f63 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts @@ -0,0 +1,36 @@ +import * as kinesis from 'aws-cdk-lib/aws-kinesis'; +import * as lambda from 'aws-cdk-lib/aws-lambda'; +import * as cdk from 'aws-cdk-lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import { TestFunction } from './test-function'; +import { KinesisEventSource, MetricType } from 'aws-cdk-lib/aws-lambda-event-sources'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'lambda-event-source-metrics-config-kinesis'); + +const fn1 = new TestFunction(stack, 'F1'); +const stream = new kinesis.Stream(stack, 'Q'); + +fn1.addEventSource(new KinesisEventSource(stream, { + startingPosition: lambda.StartingPosition.TRIM_HORIZON, + tumblingWindow: cdk.Duration.seconds(60), + metricsConfig: { + metrics: [], + }, +})); + +const fn2 = new TestFunction(stack, 'F2'); +fn2.addEventSource(new KinesisEventSource(stream, { + startingPosition: lambda.StartingPosition.TRIM_HORIZON, + tumblingWindow: cdk.Duration.seconds(60), + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + }, +})); + +new integ.IntegTest(app, 'lambda-event-source-kinesis-with-metrics', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/integ.json new file mode 100644 index 0000000000000..a779b0d0ad893 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "lambda-event-source-sqs-with-metrics/DefaultTest": { + "stacks": [ + "lambda-event-source-metrics-config-sqs" + ], + "assertionStack": "lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert", + "assertionStackName": "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json new file mode 100644 index 0000000000000..66bd39efac58c --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf": { + "source": { + "path": "lambda-event-source-metrics-config-sqs.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json new file mode 100644 index 0000000000000..4d9ae255f7dfb --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json @@ -0,0 +1,239 @@ +{ + "Resources": { + "F1ServiceRoleCCF1273A": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "F1ServiceRoleDefaultPolicy1610A985": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "F1ServiceRoleDefaultPolicy1610A985", + "Roles": [ + { + "Ref": "F1ServiceRoleCCF1273A" + } + ] + } + }, + "F1EAD92DBE": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "F1ServiceRoleCCF1273A", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "F1ServiceRoleDefaultPolicy1610A985", + "F1ServiceRoleCCF1273A" + ] + }, + "F1SqsEventSourcelambdaeventsourcemetricsconfigsqsQ5E4B9C7541A3CDAE": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 5, + "EventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "FunctionName": { + "Ref": "F1EAD92DBE" + } + } + }, + "Q63C6E3AB": { + "Type": "AWS::SQS::Queue", + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "F2ServiceRole7F7C6006": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "F2ServiceRoleDefaultPolicy999D30A8": { + "Type": "AWS::IAM::Policy", + "Properties": { + "PolicyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "PolicyName": "F2ServiceRoleDefaultPolicy999D30A8", + "Roles": [ + { + "Ref": "F2ServiceRole7F7C6006" + } + ] + } + }, + "F23BAC7B9C": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "Handler": "index.handler", + "Role": { + "Fn::GetAtt": [ + "F2ServiceRole7F7C6006", + "Arn" + ] + }, + "Runtime": "nodejs18.x" + }, + "DependsOn": [ + "F2ServiceRoleDefaultPolicy999D30A8", + "F2ServiceRole7F7C6006" + ] + }, + "F2SqsEventSourcelambdaeventsourcemetricsconfigsqsQ5E4B9C754C1C02FC": { + "Type": "AWS::Lambda::EventSourceMapping", + "Properties": { + "BatchSize": 5, + "EventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "FunctionName": { + "Ref": "F23BAC7B9C" + } + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets.json new file mode 100644 index 0000000000000..02fd7ef4decb8 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json new file mode 100644 index 0000000000000..b4af7f5c51a98 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json @@ -0,0 +1,163 @@ +{ + "version": "38.0.1", + "artifacts": { + "lambda-event-source-metrics-config-sqs.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambda-event-source-metrics-config-sqs.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambda-event-source-metrics-config-sqs": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambda-event-source-metrics-config-sqs.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambda-event-source-metrics-config-sqs.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambda-event-source-metrics-config-sqs.assets" + ], + "metadata": { + "/lambda-event-source-metrics-config-sqs/F1/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1ServiceRoleCCF1273A" + } + ], + "/lambda-event-source-metrics-config-sqs/F1/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1ServiceRoleDefaultPolicy1610A985" + } + ], + "/lambda-event-source-metrics-config-sqs/F1/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1EAD92DBE" + } + ], + "/lambda-event-source-metrics-config-sqs/F1/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F1SqsEventSourcelambdaeventsourcemetricsconfigsqsQ5E4B9C7541A3CDAE" + } + ], + "/lambda-event-source-metrics-config-sqs/Q/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Q63C6E3AB" + } + ], + "/lambda-event-source-metrics-config-sqs/F2/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2ServiceRole7F7C6006" + } + ], + "/lambda-event-source-metrics-config-sqs/F2/ServiceRole/DefaultPolicy/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2ServiceRoleDefaultPolicy999D30A8" + } + ], + "/lambda-event-source-metrics-config-sqs/F2/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F23BAC7B9C" + } + ], + "/lambda-event-source-metrics-config-sqs/F2/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "F2SqsEventSourcelambdaeventsourcemetricsconfigsqsQ5E4B9C754C1C02FC" + } + ], + "/lambda-event-source-metrics-config-sqs/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-metrics-config-sqs/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-metrics-config-sqs" + }, + "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json", + "terminationProtection": false, + "validateOnSynth": false, + "notificationArns": [], + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.assets" + ], + "metadata": { + "/lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json new file mode 100644 index 0000000000000..fedb7152e8db1 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json @@ -0,0 +1,471 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "lambda-event-source-metrics-config-sqs": { + "id": "lambda-event-source-metrics-config-sqs", + "path": "lambda-event-source-metrics-config-sqs", + "children": { + "F1": { + "id": "F1", + "path": "lambda-event-source-metrics-config-sqs/F1", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-sqs/F1/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-sqs/F1/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F1/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-sqs/F1/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F1/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "F1ServiceRoleDefaultPolicy1610A985", + "roles": [ + { + "Ref": "F1ServiceRoleCCF1273A" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F1/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "F1ServiceRoleCCF1273A", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75": { + "id": "SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75", + "path": "lambda-event-source-metrics-config-sqs/F1/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F1/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 5, + "eventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "functionName": { + "Ref": "F1EAD92DBE" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "Q": { + "id": "Q", + "path": "lambda-event-source-metrics-config-sqs/Q", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/Q/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::SQS::Queue", + "aws:cdk:cloudformation:props": {} + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.CfnQueue", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_sqs.Queue", + "version": "0.0.0" + } + }, + "F2": { + "id": "F2", + "path": "lambda-event-source-metrics-config-sqs/F2", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "lambda-event-source-metrics-config-sqs/F2/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "lambda-event-source-metrics-config-sqs/F2/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F2/ServiceRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "lambda.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnRole", + "version": "0.0.0" + } + }, + "DefaultPolicy": { + "id": "DefaultPolicy", + "path": "lambda-event-source-metrics-config-sqs/F2/ServiceRole/DefaultPolicy", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F2/ServiceRole/DefaultPolicy/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Policy", + "aws:cdk:cloudformation:props": { + "policyDocument": { + "Statement": [ + { + "Action": [ + "sqs:ChangeMessageVisibility", + "sqs:DeleteMessage", + "sqs:GetQueueAttributes", + "sqs:GetQueueUrl", + "sqs:ReceiveMessage" + ], + "Effect": "Allow", + "Resource": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + } + } + ], + "Version": "2012-10-17" + }, + "policyName": "F2ServiceRoleDefaultPolicy999D30A8", + "roles": [ + { + "Ref": "F2ServiceRole7F7C6006" + } + ] + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.CfnPolicy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Policy", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F2/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "exports.handler = async function handler(event) {\n console.log('event:', JSON.stringify(event, undefined, 2));\n return { event };\n}" + }, + "handler": "index.handler", + "role": { + "Fn::GetAtt": [ + "F2ServiceRole7F7C6006", + "Arn" + ] + }, + "runtime": "nodejs18.x" + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + }, + "SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75": { + "id": "SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75", + "path": "lambda-event-source-metrics-config-sqs/F2/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75", + "children": { + "Resource": { + "id": "Resource", + "path": "lambda-event-source-metrics-config-sqs/F2/SqsEventSource:lambdaeventsourcemetricsconfigsqsQ5E4B9C75/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::EventSourceMapping", + "aws:cdk:cloudformation:props": { + "batchSize": 5, + "eventSourceArn": { + "Fn::GetAtt": [ + "Q63C6E3AB", + "Arn" + ] + }, + "functionName": { + "Ref": "F23BAC7B9C" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnEventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.EventSourceMapping", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-metrics-config-sqs/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-metrics-config-sqs/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "lambda-event-source-sqs-with-metrics": { + "id": "lambda-event-source-sqs-with-metrics", + "path": "lambda-event-source-sqs-with-metrics", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "lambda-event-source-sqs-with-metrics/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "lambda-event-source-sqs-with-metrics/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-event-source-sqs-with-metrics/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts new file mode 100644 index 0000000000000..82750a9d19ce3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts @@ -0,0 +1,36 @@ +import * as sqs from 'aws-cdk-lib/aws-sqs'; +import * as cdk from 'aws-cdk-lib'; +import { TestFunction } from './test-function'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import { MetricType, SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'lambda-event-source-metrics-config-sqs'); + +const fn1 = new TestFunction(stack, 'F1'); +const queue = new sqs.Queue(stack, 'Q'); +const eventSource1 = new SqsEventSource(queue, { + batchSize: 5, + metricsConfig: { + metrics: [], + }, +}); + +fn1.addEventSource(eventSource1); + +const fn2 = new TestFunction(stack, 'F2'); +const eventSource2 = new SqsEventSource(queue, { + batchSize: 5, + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + }, +}); + +fn2.addEventSource(eventSource2); + +new integ.IntegTest(app, 'lambda-event-source-sqs-with-metrics', { + testCases: [stack], +}); + +app.synth(); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/dynamodb.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/dynamodb.ts index ec349f0ed0fa6..a2aed0616eee1 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/dynamodb.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/dynamodb.ts @@ -29,7 +29,10 @@ export class DynamoEventSource extends StreamEventSource { } const eventSourceMapping = target.addEventSourceMapping(`DynamoDBEventSource:${Names.nodeUniqueId(this.table.node)}`, - this.enrichMappingOptions({ eventSourceArn: this.table.tableStreamArn }), + this.enrichMappingOptions({ + eventSourceArn: this.table.tableStreamArn, + metricsConfig: this.props.metricsConfig, + }), ); this._eventSourceMappingId = eventSourceMapping.eventSourceMappingId; this._eventSourceMappingArn = eventSourceMapping.eventSourceMappingArn; diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kinesis.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kinesis.ts index aa0fccd26de66..703b464882a91 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kinesis.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/kinesis.ts @@ -36,6 +36,7 @@ export class KinesisEventSource extends StreamEventSource { this.enrichMappingOptions({ eventSourceArn: this.stream.streamArn, startingPositionTimestamp: this.startingPositionTimestamp, + metricsConfig: this.props.metricsConfig, }), ); this._eventSourceMappingId = eventSourceMapping.eventSourceMappingId; diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts index bcf6f4adf573d..58296e26698ed 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts @@ -68,6 +68,33 @@ export interface SqsEventSourceProps { * @default - No specific limit. */ readonly maxConcurrency?: number; + + /** + * Configuration for enhanced monitoring metrics collection + * When specified, enables collection of additional metrics for the stream event source + * + * @default - Enhanced monitoring is disabled + */ + readonly metricsConfig?: MetricsConfig; +} + +enum MetricType{ + /** + * Event Count metrics provide insights into the processing behavior of your event source mapping, + * including the number of events successfully processed, filtered out, or dropped. + * These metrics help you monitor the flow and status of events through your event source mapping. + */ + EVENT_COUNT = 'EventCount', +} + +/** + * Configuration for collecting metrics from the event source + */ +interface MetricsConfig { + /** + * List of metric types to enable for this event source + */ + readonly metrics: MetricType[]; } /** @@ -106,6 +133,7 @@ export class SqsEventSource implements lambda.IEventSource { eventSourceArn: this.queue.queueArn, filters: this.props.filters, filterEncryption: this.props.filterEncryption, + metricsConfig: this.props.metricsConfig, }); this._eventSourceMappingId = eventSourceMapping.eventSourceMappingId; this._eventSourceMappingArn = eventSourceMapping.eventSourceMappingArn; diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts index 414de7472f0e5..893396e3c4713 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts @@ -137,6 +137,33 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { */ readonly filterEncryption?: IKey; + /** + * Configuration for enhanced monitoring metrics collection + * When specified, enables collection of additional metrics for the stream event source + * + * @default - Enhanced monitoring is disabled + */ + readonly metricsConfig?: MetricsConfig; + +} + +export enum MetricType { + /** + * Event Count metrics provide insights into the processing behavior of your event source mapping, + * including the number of events successfully processed, filtered out, or dropped. + * These metrics help you monitor the flow and status of events through your event source mapping. + */ + EVENT_COUNT = 'EventCount', +} + +/** + * Configuration for collecting metrics from the event source + */ +export interface MetricsConfig { + /** + * List of metric types to enable for this event source + */ + readonly metrics: MetricType[]; } /** diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts index 92185d565598b..9eacfa1c96bcd 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts @@ -7,6 +7,7 @@ import { Bucket } from '../../aws-s3'; import * as sqs from '../../aws-sqs'; import * as cdk from '../../core'; import * as sources from '../lib'; +import { MetricType } from '../lib'; /* eslint-disable quote-props */ @@ -998,4 +999,64 @@ describe('DynamoEventSource', () => { 'StartingPosition': 'LATEST', }); }); + + test('event source disabled', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const table = new dynamodb.Table(stack, 'T', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + stream: dynamodb.StreamViewType.NEW_IMAGE, + }); + + // WHEN + fn.addEventSource(new sources.DynamoEventSource(table, { + startingPosition: lambda.StartingPosition.LATEST, + enabled: false, + metricsConfig: { + metrics: [], + }, + })); + + //THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + 'Enabled': false, + MetricsConfig: { + Metrics: [], + }, + }); + }); + + test('event source disabled', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const table = new dynamodb.Table(stack, 'T', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + stream: dynamodb.StreamViewType.NEW_IMAGE, + }); + + // WHEN + fn.addEventSource(new sources.DynamoEventSource(table, { + startingPosition: lambda.StartingPosition.LATEST, + enabled: false, + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + }, + })); + + //THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + 'Enabled': false, + MetricsConfig: { + Metrics: ['EventCount'], + }, + }); + }); }); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts index dd8f69458a8ab..d1144ab205e36 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts @@ -331,4 +331,51 @@ describe('KinesisEventSource', () => { }); + test('metrics config', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const stream = new kinesis.Stream(stack, 'S'); + const eventSource = new sources.KinesisEventSource(stream, { + startingPosition: lambda.StartingPosition.LATEST, + enabled: false, + metricsConfig: { + metrics: [], + }, + }); + + // WHEN + fn.addEventSource(eventSource); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + MetricsConfig: { + Metrics: [], + }, + }); + }); + + test('metrics config', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const stream = new kinesis.Stream(stack, 'S'); + const eventSource = new sources.KinesisEventSource(stream, { + startingPosition: lambda.StartingPosition.LATEST, + enabled: false, + metricsConfig: { + metrics: [sources.MetricType.EVENT_COUNT], + }, + }); + + // WHEN + fn.addEventSource(eventSource); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + MetricsConfig: { + Metrics: ['EventCount'], + }, + }); + }); }); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts index 3865e02f63039..938bd13167e33 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts @@ -567,4 +567,46 @@ describe('SQSEventSource', () => { maxConcurrency: 1, }))).toThrow(/maxConcurrency must be between 2 and 1000 concurrent instances/); }); + + test('adding maxConcurrency of 5', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const q = new sqs.Queue(stack, 'Q'); + + // WHEN + fn.addEventSource(new sources.SqsEventSource(q, { + maxConcurrency: 5, + metricsConfig: { + metrics: [], + }, + })); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + ScalingConfig: { MaximumConcurrency: 5 }, + MetricsConfig: { Metrics: [] }, + }); + }); + + test('adding maxConcurrency of 5', () => { + // GIVEN + const stack = new cdk.Stack(); + const fn = new TestFunction(stack, 'Fn'); + const q = new sqs.Queue(stack, 'Q'); + + // WHEN + fn.addEventSource(new sources.SqsEventSource(q, { + maxConcurrency: 5, + metricsConfig: { + metrics: [sources.MetricType.EVENT_COUNT], + }, + })); + + // THEN + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + ScalingConfig: { MaximumConcurrency: 5 }, + MetricsConfig: { Metrics: ['EventCount'] }, + }); + }); }); diff --git a/packages/aws-cdk-lib/aws-lambda/README.md b/packages/aws-cdk-lib/aws-lambda/README.md index 02fc358c4b38e..4f979c367e526 100644 --- a/packages/aws-cdk-lib/aws-lambda/README.md +++ b/packages/aws-cdk-lib/aws-lambda/README.md @@ -852,6 +852,34 @@ fn.addEventSource(new eventsources.DynamoEventSource(table, { } ``` +### Observability + +Customers can now opt-in to get enhanced metrics for their event source mapping that capture each stage of processing using the `MetrcisConfig` property. + +The following code shows how to opt in for the enhanced metrics. + +```ts +import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources'; +import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; +import { MetricType } from 'aws-cdk-lib/aws-lambda-event-sources/lib'; + +declare const fn: lambda.Function; +const table = new dynamodb.Table(this, 'Table', { + partitionKey: { + name: 'id', + type: dynamodb.AttributeType.STRING, + }, + stream: dynamodb.StreamViewType.NEW_IMAGE, +}); + +fn.addEventSource(new eventsources.DynamoEventSource(table, { + startingPosition: lambda.StartingPosition.LATEST, + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + } +})); +``` + See the documentation for the __@aws-cdk/aws-lambda-event-sources__ module for more details. ## Imported Lambdas diff --git a/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts b/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts index a441ce148788a..842cdeb66fecc 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/event-source-mapping.ts @@ -269,6 +269,33 @@ export interface EventSourceMappingOptions { * @default false */ readonly supportS3OnFailureDestination?: boolean; + + /** + * Configuration for enhanced monitoring metrics collection + * When specified, enables collection of additional metrics for the stream event source + * + * @default - Enhanced monitoring is disabled + */ + readonly metricsConfig?: MetricsConfig; +} + +export enum MetricType { + /** + * Event Count metrics provide insights into the processing behavior of your event source mapping, + * including the number of events successfully processed, filtered out, or dropped. + * These metrics help you monitor the flow and status of events through your event source mapping. + */ + EVENT_COUNT = 'EventCount', +} + +/** + * Configuration for collecting metrics from the event source + */ +export interface MetricsConfig { + /** + * List of metric types to enable for this event source + */ + readonly metrics: MetricType[]; } /** @@ -455,6 +482,7 @@ export class EventSourceMapping extends cdk.Resource implements IEventSourceMapp kmsKeyArn: props.filterEncryption?.keyArn, selfManagedKafkaEventSourceConfig: props.kafkaBootstrapServers ? consumerGroupConfig : undefined, amazonManagedKafkaEventSourceConfig: props.eventSourceArn ? consumerGroupConfig : undefined, + metricsConfig: props.metricsConfig, }); this.eventSourceMappingId = cfnEventSourceMapping.ref; this.eventSourceMappingArn = EventSourceMapping.formatArn(this, this.eventSourceMappingId); diff --git a/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts b/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts index 6eafc9267471d..ea58025283601 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts @@ -1,5 +1,6 @@ import { Match, Template } from '../../assertions'; import { Key } from '../../aws-kms'; +import { MetricType } from '../../aws-lambda-event-sources'; import * as cdk from '../../core'; import * as lambda from '../lib'; import { Code, EventSourceMapping, Function, Runtime, Alias, StartingPosition, FilterRule, FilterCriteria } from '../lib'; @@ -492,4 +493,44 @@ describe('event source mapping', () => { startingPositionTimestamp: 1640995200, })).toThrow(/startingPositionTimestamp can only be used when startingPosition is AT_TIMESTAMP/); }); + + test('adding metrics config', () => { + new EventSourceMapping(stack, 'test', { + target: fn, + eventSourceArn: '', + startingPosition: StartingPosition.AT_TIMESTAMP, + startingPositionTimestamp: 1640995200, + metricsConfig: { + metrics: [], + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + StartingPosition: 'AT_TIMESTAMP', + StartingPositionTimestamp: 1640995200, + MetricsConfig: { + Metrics: [], + }, + }); + }); + + test('adding metrics config', () => { + new EventSourceMapping(stack, 'test', { + target: fn, + eventSourceArn: '', + startingPosition: StartingPosition.AT_TIMESTAMP, + startingPositionTimestamp: 1640995200, + metricsConfig: { + metrics: [MetricType.EVENT_COUNT], + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', { + StartingPosition: 'AT_TIMESTAMP', + StartingPositionTimestamp: 1640995200, + MetricsConfig: { + Metrics: ['EventCount'], + }, + }); + }); }); diff --git a/packages/aws-cdk-lib/awslint.json b/packages/aws-cdk-lib/awslint.json index ffc97a8a2609d..528f143682a16 100644 --- a/packages/aws-cdk-lib/awslint.json +++ b/packages/aws-cdk-lib/awslint.json @@ -204,6 +204,27 @@ "attribute-tag:aws-cdk-lib.aws_ec2.BastionHostLinux.instance", "attribute-tag:aws-cdk-lib.aws_ec2.Instance.instance", "attribute-tag:aws-cdk-lib.aws_lambda.EventSourceMapping.eventSourceMappingArn", + "docs-public-apis:aws-cdk-lib.aws_lambda.EventSourceMappingOptions.metricsConfig", + "props-default-doc:aws-cdk-lib.aws_lambda.EventSourceMappingOptions.metricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda.MetricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda.MetricsConfig.metrics", + "props-default-doc:aws-cdk-lib.aws_lambda.MetricsConfig.metrics", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.MetricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.MetricsConfig.metrics", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.SqsEventSourceProps.metricsConfig", + "props-default-doc:aws-cdk-lib.aws_lambda_event_sources.SqsEventSourceProps.metricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.stream.MetricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.stream.MetricsConfig.metrics", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.stream.StreamEventSourceProps.metricsConfig", + "props-default-doc:aws-cdk-lib.aws_lambda_event_sources.stream.StreamEventSourceProps.metricsConfig", + "docs-public-apis:aws-cdk-lib.aws_lambda.MetricType", + "docs-public-apis:aws-cdk-lib.aws_lambda.MetricType.EVENT_COUNT", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.MetricType", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.MetricType.EVENT_COUNT", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.stream.MetricType", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.stream.MetricType.EVENT_COUNT", + "docs-public-apis:aws-cdk-lib.aws_lambda_event_sources.StreamEventSourceProps.metricsConfig", + "props-default-doc:aws-cdk-lib.aws_lambda_event_sources.StreamEventSourceProps.metricsConfig", "attribute-tag:aws-cdk-lib.aws_rds.DatabaseSecret.secretName", "attribute-tag:aws-cdk-lib.aws_rds.DatabaseSecret.secretFullArn", "attribute-tag:aws-cdk-lib.aws_secretsmanager.Secret.secretName", diff --git a/tools/@aws-cdk/spec2cdk/temporary-schemas/us-east-1/aws-lambda-event-source-metrics-config.json b/tools/@aws-cdk/spec2cdk/temporary-schemas/us-east-1/aws-lambda-event-source-metrics-config.json new file mode 100644 index 0000000000000..e2219c42ed97f --- /dev/null +++ b/tools/@aws-cdk/spec2cdk/temporary-schemas/us-east-1/aws-lambda-event-source-metrics-config.json @@ -0,0 +1,512 @@ +{ + "typeName" : "AWS::Lambda::EventSourceMapping", + "description" : "Resource Type definition for AWS::Lambda::EventSourceMapping", + "additionalProperties" : false, + "properties" : { + "Id": { + "description": "Event Source Mapping Identifier UUID.", + "type": "string", + "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}", + "minLength": 36, + "maxLength": 36 + }, + "BatchSize": { + "description": "The maximum number of items to retrieve in a single batch.", + "type": "integer", + "minimum": 1, + "maximum": 10000 + }, + "BisectBatchOnFunctionError": { + "description": "(Streams) If the function returns an error, split the batch in two and retry.", + "type": "boolean" + }, + "DestinationConfig": { + "description": "(Kinesis, DynamoDB, Amazon MSK, and self-managed Kafka event sources only) A configuration object that specifies the destination of an event after Lambda processes it.", + "$ref": "#/definitions/DestinationConfig" + }, + "Enabled": { + "description": "Disables the event source mapping to pause polling and invocation.", + "type": "boolean" + }, + "EventSourceArn": { + "description": "The Amazon Resource Name (ARN) of the event source.", + "type": "string", + "pattern": "arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\\-])+:([a-z]{2}(-gov)?(-iso([a-z])?)?-[a-z]+-\\d{1})?:(\\d{12})?:(.*)", + "minLength": 12, + "maxLength": 1024 + }, + "EventSourceMappingArn": { + "description": "The Amazon Resource Name (ARN) of the event source mapping resource.", + "type": "string", + "pattern": "arn:(aws[a-zA-Z-]*)?:lambda:[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:event-source-mapping:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}", + "minLength": 85, + "maxLength": 120 + }, + "FilterCriteria": { + "description": "The filter criteria to control event filtering.", + "$ref": "#/definitions/FilterCriteria" + }, + "KmsKeyArn": { + "description": "The Amazon Resource Name (ARN) of the KMS key.", + "type": "string", + "pattern": "(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()", + "minLength": 12, + "maxLength": 2048 + }, + "FunctionName": { + "description": "The name of the Lambda function.", + "type": "string", + "pattern": "(arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?(-iso([a-z])?)?-[a-z]+-\\d{1}:)?(\\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\\$LATEST|[a-zA-Z0-9-_]+))?", + "minLength": 1, + "maxLength": 140 + }, + "MaximumBatchingWindowInSeconds": { + "description": "(Streams) The maximum amount of time to gather records before invoking the function, in seconds.", + "type": "integer", + "minimum": 0, + "maximum": 300 + }, + "MaximumRecordAgeInSeconds": { + "description": "(Streams) The maximum age of a record that Lambda sends to a function for processing.", + "type": "integer", + "minimum": -1, + "maximum": 604800 + }, + "MaximumRetryAttempts": { + "description": "(Streams) The maximum number of times to retry when the function returns an error.", + "type": "integer", + "minimum": -1, + "maximum": 10000 + }, + "ParallelizationFactor": { + "description": "(Streams) The number of batches to process from each shard concurrently.", + "type": "integer", + "minimum": 1, + "maximum": 10 + }, + "StartingPosition": { + "description": "The position in a stream from which to start reading. Required for Amazon Kinesis and Amazon DynamoDB Streams sources.", + "type": "string", + "pattern": "(LATEST|TRIM_HORIZON|AT_TIMESTAMP)+", + "minLength": 6, + "maxLength": 12 + }, + "StartingPositionTimestamp": { + "description": "With StartingPosition set to AT_TIMESTAMP, the time from which to start reading, in Unix time seconds.", + "type": "number" + }, + "Tags" : { + "description": "A list of tags to apply to event source mapping resource", + "type": "array", + "uniqueItems": true, + "insertionOrder": false, + "items": { + "$ref": "#/definitions/Tag" + } + }, + "Topics": { + "description": "(Kafka) A list of Kafka topics.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "pattern": "^[^.]([a-zA-Z0-9\\-_.]+)", + "minLength": 1, + "maxLength": 249 + }, + "minItems": 1, + "maxItems": 1 + }, + "Queues": { + "description": "(ActiveMQ) A list of ActiveMQ queues.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "pattern": "[\\s\\S]*", + "minLength": 1, + "maxLength": 1000 + }, + "minItems": 1, + "maxItems": 1 + }, + "SourceAccessConfigurations": { + "description": "A list of SourceAccessConfiguration.", + "type": "array", + "uniqueItems": true, + "items": { + "$ref": "#/definitions/SourceAccessConfiguration" + }, + "minItems": 1, + "maxItems": 22 + }, + "TumblingWindowInSeconds": { + "description": "(Streams) Tumbling window (non-overlapping time window) duration to perform aggregations.", + "type": "integer", + "minimum": 0, + "maximum": 900 + }, + "FunctionResponseTypes": { + "description": "(Streams) A list of response types supported by the function.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "ReportBatchItemFailures" + ] + }, + "minLength": 0, + "maxLength": 1 + }, + "SelfManagedEventSource": { + "description": "Self-managed event source endpoints.", + "$ref": "#/definitions/SelfManagedEventSource" + }, + "AmazonManagedKafkaEventSourceConfig": { + "description": "Specific configuration settings for an MSK event source.", + "$ref": "#/definitions/AmazonManagedKafkaEventSourceConfig" + }, + "SelfManagedKafkaEventSourceConfig": { + "description": "Specific configuration settings for a Self-Managed Apache Kafka event source.", + "$ref": "#/definitions/SelfManagedKafkaEventSourceConfig" + }, + "ScalingConfig": { + "description": "The scaling configuration for the event source.", + "$ref": "#/definitions/ScalingConfig" + }, + "DocumentDBEventSourceConfig": { + "description": "Document db event source config.", + "$ref": "#/definitions/DocumentDBEventSourceConfig" + }, + "ProvisionedPollerConfig": { + "description": "Event processor config.", + "$ref": "#/definitions/ProvisionedPollerConfig" + }, + "MetricsConfig": { + "description": "Metrics config for Event Source Mapping Metrics.", + "$ref": "#/definitions/MetricsConfig" + } + }, + "definitions" : { + "DestinationConfig" : { + "type" : "object", + "additionalProperties" : false, + "description": "A configuration object that specifies the destination of an event after Lambda processes it.", + "properties" : { + "OnFailure": { + "description": "A destination for records of invocations that failed processing.", + "$ref": "#/definitions/OnFailure" + } + } + }, + "FilterCriteria": { + "type": "object", + "description": "The filter criteria to control event filtering.", + "additionalProperties" : false, + "properties": { + "Filters": { + "description": "List of filters of this FilterCriteria", + "type": "array", + "uniqueItems": true, + "items": { + "$ref": "#/definitions/Filter" + }, + "minItems": 1, + "maxItems": 20 + } + } + }, + "Filter": { + "type": "object", + "description": "The filter object that defines parameters for ESM filtering.", + "additionalProperties" : false, + "properties": { + "Pattern": { + "type": "string", + "description": "The filter pattern that defines which events should be passed for invocations.", + "pattern": ".*", + "minLength": 0, + "maxLength": 4096 + } + } + }, + "OnFailure": { + "type" : "object", + "description" : "A destination for records of invocations that failed processing.", + "additionalProperties" : false, + "properties" : { + "Destination": { + "description": "The Amazon Resource Name (ARN) of the destination resource.", + "type": "string", + "pattern": "arn:(aws[a-zA-Z0-9-]*):([a-zA-Z0-9\\-])+:([a-z]{2}(-gov)?(-iso([a-z])?)?-[a-z]+-\\d{1})?:(\\d{12})?:(.*)", + "minLength": 12, + "maxLength": 1024 + } + } + }, + "SourceAccessConfiguration" : { + "type" : "object", + "additionalProperties" : false, + "description": "The configuration used by AWS Lambda to access event source", + "properties" : { + "Type" : { + "description": "The type of source access configuration.", + "enum": [ + "BASIC_AUTH", + "VPC_SUBNET", + "VPC_SECURITY_GROUP", + "SASL_SCRAM_512_AUTH", + "SASL_SCRAM_256_AUTH", + "VIRTUAL_HOST", + "CLIENT_CERTIFICATE_TLS_AUTH", + "SERVER_ROOT_CA_CERTIFICATE" + ], + "type": "string" + }, + "URI" : { + "description": "The URI for the source access configuration resource.", + "type": "string", + "pattern": "[a-zA-Z0-9-\\/*:_+=.@-]*", + "minLength": 1, + "maxLength": 200 + } + } + }, + "SelfManagedEventSource" : { + "type": "object", + "additionalProperties": false, + "description": "The configuration used by AWS Lambda to access a self-managed event source.", + "properties": { + "Endpoints": { + "description": "The endpoints for a self-managed event source.", + "$ref": "#/definitions/Endpoints" + } + } + }, + "Endpoints" : { + "type": "object", + "additionalProperties": false, + "description": "The endpoints used by AWS Lambda to access a self-managed event source.", + "properties": { + "KafkaBootstrapServers": { + "type": "array", + "description": "A list of Kafka server endpoints.", + "uniqueItems": true, + "items": { + "type": "string", + "description": "The URL of a Kafka server.", + "pattern": "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]*[a-zA-Z0-9])\\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\\-]*[A-Za-z0-9]):[0-9]{1,5}", + "minLength": 1, + "maxLength": 300 + }, + "minItems": 1, + "maxItems": 10 + } + } + }, + "ConsumerGroupId": { + "description": "The identifier for the Kafka Consumer Group to join.", + "type": "string", + "pattern": "[a-zA-Z0-9-\\/*:_+=.@-]*", + "minLength": 1, + "maxLength": 200 + }, + "AmazonManagedKafkaEventSourceConfig": { + "description": "Specific configuration settings for an MSK event source.", + "type": "object", + "additionalProperties": false, + "properties": { + "ConsumerGroupId": { + "description": "The identifier for the Kafka Consumer Group to join.", + "$ref": "#/definitions/ConsumerGroupId" + } + } + }, + "SelfManagedKafkaEventSourceConfig": { + "description": "Specific configuration settings for a Self-Managed Apache Kafka event source.", + "type": "object", + "additionalProperties": false, + "properties": { + "ConsumerGroupId": { + "description": "The identifier for the Kafka Consumer Group to join.", + "$ref": "#/definitions/ConsumerGroupId" + } + } + }, + "MaximumConcurrency": { + "description": "The maximum number of concurrent functions that an event source can invoke.", + "type": "integer", + "minimum": 2, + "maximum": 1000 + }, + "ScalingConfig": { + "description": "The scaling configuration for the event source.", + "type": "object", + "additionalProperties": false, + "properties": { + "MaximumConcurrency": { + "description": "The maximum number of concurrent functions that the event source can invoke.", + "$ref": "#/definitions/MaximumConcurrency" + } + } + }, + "Tag" : { + "type" : "object", + "additionalProperties": false, + "properties" : { + "Key" : { + "type" : "string", + "description" : "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.", + "minLength" : 1, + "maxLength" : 128 + }, + "Value" : { + "type" : "string", + "description" : "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.", + "minLength" : 0, + "maxLength" : 256 + } + }, + "required" : [ + "Key" + ] + }, + "DocumentDBEventSourceConfig": { + "description": "Document db event source config.", + "type": "object", + "additionalProperties": false, + "properties": { + "DatabaseName": { + "description": "The database name to connect to.", + "type": "string", + "minLength": 1, + "maxLength": 63 + }, + "CollectionName": { + "description": "The collection name to connect to.", + "type": "string", + "minLength": 1, + "maxLength": 57 + }, + "FullDocument": { + "description": "Include full document in change stream response. The default option will only send the changes made to documents to Lambda. If you want the complete document sent to Lambda, set this to UpdateLookup.", + "type": "string", + "enum": [ + "UpdateLookup", + "Default" + ] + } + } + }, + "ProvisionedPollerConfig": { + "description": "ProvisionedPollerConfig.", + "type": "object", + "additionalProperties": false, + "properties": { + "MinimumPollers": { + "description": "Minimum poller count.", + "type": "integer", + "minimum": 1, + "maximum": 3000 + }, + "MaximumPollers": { + "description": "Maximum poller count.", + "type": "integer", + "minimum": 1, + "maximum": 3000 + } + } + }, + "MetricsConfig": { + "description": "Metrics config for Event Source Mapping Metrics.", + "type": "object", + "additionalProperties": false, + "properties": { + "Metrics": { + "description": "Metric groups to enable.", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "enum": [ + "EventCount" + ] + }, + "minItems": 0, + "maxItems": 1 + } + } + } + }, + "nonPublicProperties": [ + "/properties/ProvisionedPollerConfig" + ], + "nonPublicDefinitions": [ + "/definitions/ProvisionedPollerConfig" + ], + "required" : [ "FunctionName" ], + "createOnlyProperties" : [ + "/properties/EventSourceArn", + "/properties/StartingPosition", + "/properties/StartingPositionTimestamp", + "/properties/SelfManagedEventSource", + "/properties/AmazonManagedKafkaEventSourceConfig", + "/properties/SelfManagedKafkaEventSourceConfig" + ], + "readOnlyProperties" : [ "/properties/Id", "/properties/EventSourceMappingArn"], + "primaryIdentifier" : [ "/properties/Id" ], + "propertyTransform" : { + "/properties/StartingPositionTimestamp": "StartingPositionTimestamp * 1000" + }, + "handlers": { + "create": { + "permissions": [ + "lambda:CreateEventSourceMapping", + "lambda:GetEventSourceMapping", + "lambda:TagResource", + "kms:DescribeKey", + "kms:GenerateDataKey", + "kms:Decrypt" + ] + }, + "delete": { + "permissions": [ + "lambda:DeleteEventSourceMapping", + "lambda:GetEventSourceMapping", + "kms:Decrypt" + ] + }, + "list": { + "permissions": [ + "lambda:ListEventSourceMappings" + ] + }, + "read": { + "permissions": [ + "lambda:GetEventSourceMapping", + "lambda:ListTags", + "kms:Decrypt" + ] + }, + "update": { + "permissions": [ + "lambda:UpdateEventSourceMapping", + "lambda:GetEventSourceMapping", + "lambda:ListTags", + "lambda:TagResource", + "lambda:UntagResource", + "kms:DescribeKey", + "kms:GenerateDataKey", + "kms:Decrypt" + ] + } + }, + "tagging": { + "taggable": true, + "tagOnCreate": true, + "tagUpdatable": true, + "cloudFormationSystemTags": true, + "tagProperty": "/properties/Tags" + } +} \ No newline at end of file From 3e4d30e81fae779fd93895e18beaeda1751caf6b Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 20 Nov 2024 03:58:17 +0000 Subject: [PATCH 2/5] fix lint address comments --- .../integ.dynamodb-with-metrics-config.ts | 4 ++-- .../test/integ.kinesis-with-metrics-config.ts | 4 ++-- .../test/integ.sqs-with-metrics-config.ts | 5 +++-- .../aws-lambda-event-sources/lib/sqs.ts | 21 +----------------- .../aws-lambda-event-sources/lib/stream.ts | 22 +------------------ 5 files changed, 9 insertions(+), 47 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts index 6b393ca7e5390..2e4bfe1e2e6ac 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.dynamodb-with-metrics-config.ts @@ -3,7 +3,7 @@ import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as cdk from 'aws-cdk-lib'; import * as integ from '@aws-cdk/integ-tests-alpha'; import { TestFunction } from './test-function'; -import { DynamoEventSource, MetricType } from 'aws-cdk-lib/aws-lambda-event-sources'; +import { DynamoEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; const app = new cdk.App(); @@ -33,7 +33,7 @@ fn2.addEventSource(new DynamoEventSource(table, { batchSize: 5, startingPosition: lambda.StartingPosition.LATEST, metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, })); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts index 881d00b855f63..d4545d56a9d0f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.kinesis-with-metrics-config.ts @@ -3,7 +3,7 @@ import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as cdk from 'aws-cdk-lib'; import * as integ from '@aws-cdk/integ-tests-alpha'; import { TestFunction } from './test-function'; -import { KinesisEventSource, MetricType } from 'aws-cdk-lib/aws-lambda-event-sources'; +import { KinesisEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; const app = new cdk.App(); @@ -25,7 +25,7 @@ fn2.addEventSource(new KinesisEventSource(stream, { startingPosition: lambda.StartingPosition.TRIM_HORIZON, tumblingWindow: cdk.Duration.seconds(60), metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, })); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts index 82750a9d19ce3..bb811573b6711 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.ts @@ -1,8 +1,9 @@ import * as sqs from 'aws-cdk-lib/aws-sqs'; +import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as cdk from 'aws-cdk-lib'; import { TestFunction } from './test-function'; import * as integ from '@aws-cdk/integ-tests-alpha'; -import { MetricType, SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; +import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources'; const app = new cdk.App(); @@ -23,7 +24,7 @@ const fn2 = new TestFunction(stack, 'F2'); const eventSource2 = new SqsEventSource(queue, { batchSize: 5, metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, }); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts index 58296e26698ed..ed38512e2f91c 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/sqs.ts @@ -75,26 +75,7 @@ export interface SqsEventSourceProps { * * @default - Enhanced monitoring is disabled */ - readonly metricsConfig?: MetricsConfig; -} - -enum MetricType{ - /** - * Event Count metrics provide insights into the processing behavior of your event source mapping, - * including the number of events successfully processed, filtered out, or dropped. - * These metrics help you monitor the flow and status of events through your event source mapping. - */ - EVENT_COUNT = 'EventCount', -} - -/** - * Configuration for collecting metrics from the event source - */ -interface MetricsConfig { - /** - * List of metric types to enable for this event source - */ - readonly metrics: MetricType[]; + readonly metricsConfig?: lambda.MetricsConfig; } /** diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts index 893396e3c4713..40b765da22c63 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/lib/stream.ts @@ -143,27 +143,7 @@ export interface StreamEventSourceProps extends BaseStreamEventSourceProps { * * @default - Enhanced monitoring is disabled */ - readonly metricsConfig?: MetricsConfig; - -} - -export enum MetricType { - /** - * Event Count metrics provide insights into the processing behavior of your event source mapping, - * including the number of events successfully processed, filtered out, or dropped. - * These metrics help you monitor the flow and status of events through your event source mapping. - */ - EVENT_COUNT = 'EventCount', -} - -/** - * Configuration for collecting metrics from the event source - */ -export interface MetricsConfig { - /** - * List of metric types to enable for this event source - */ - readonly metrics: MetricType[]; + readonly metricsConfig?: lambda.MetricsConfig; } /** From 4b037642cc10cb25dc476d003958278a5b51de1b Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 20 Nov 2024 04:31:52 +0000 Subject: [PATCH 3/5] fix test --- .../aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts | 3 +-- .../aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts | 2 +- packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts | 2 +- .../aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts index 9eacfa1c96bcd..d340c31c79e0b 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/dynamo.test.ts @@ -7,7 +7,6 @@ import { Bucket } from '../../aws-s3'; import * as sqs from '../../aws-sqs'; import * as cdk from '../../core'; import * as sources from '../lib'; -import { MetricType } from '../lib'; /* eslint-disable quote-props */ @@ -1047,7 +1046,7 @@ describe('DynamoEventSource', () => { startingPosition: lambda.StartingPosition.LATEST, enabled: false, metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, })); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts index d1144ab205e36..5901521db3a9d 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/kinesis.test.ts @@ -364,7 +364,7 @@ describe('KinesisEventSource', () => { startingPosition: lambda.StartingPosition.LATEST, enabled: false, metricsConfig: { - metrics: [sources.MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, }); diff --git a/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts b/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts index 938bd13167e33..9e47bbd0b40dd 100644 --- a/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts +++ b/packages/aws-cdk-lib/aws-lambda-event-sources/test/sqs.test.ts @@ -599,7 +599,7 @@ describe('SQSEventSource', () => { fn.addEventSource(new sources.SqsEventSource(q, { maxConcurrency: 5, metricsConfig: { - metrics: [sources.MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, })); diff --git a/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts b/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts index ea58025283601..315074ec62210 100644 --- a/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts +++ b/packages/aws-cdk-lib/aws-lambda/test/event-source-mapping.test.ts @@ -1,6 +1,5 @@ import { Match, Template } from '../../assertions'; import { Key } from '../../aws-kms'; -import { MetricType } from '../../aws-lambda-event-sources'; import * as cdk from '../../core'; import * as lambda from '../lib'; import { Code, EventSourceMapping, Function, Runtime, Alias, StartingPosition, FilterRule, FilterCriteria } from '../lib'; @@ -521,7 +520,7 @@ describe('event source mapping', () => { startingPosition: StartingPosition.AT_TIMESTAMP, startingPositionTimestamp: 1640995200, metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], }, }); From 1cce6c5d73d968d4141df20d43d9643dbf23cada Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 20 Nov 2024 05:13:50 +0000 Subject: [PATCH 4/5] update integ --- ...ambda-event-source-metrics-config-sqs.assets.json | 4 ++-- ...bda-event-source-metrics-config-sqs.template.json | 8 ++++++++ .../manifest.json | 4 +--- .../tree.json | 12 ++++++++++-- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json index 66bd39efac58c..902244e2f442b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.assets.json @@ -1,7 +1,7 @@ { "version": "38.0.1", "files": { - "669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf": { + "5d4025b6edf3c156b92b7e7cb9903ece5091d3b6ad4ddd4b70d00a4817b044a2": { "source": { "path": "lambda-event-source-metrics-config-sqs.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf.json", + "objectKey": "5d4025b6edf3c156b92b7e7cb9903ece5091d3b6ad4ddd4b70d00a4817b044a2.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json index 4d9ae255f7dfb..357a5fe850a5f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/lambda-event-source-metrics-config-sqs.template.json @@ -95,6 +95,9 @@ }, "FunctionName": { "Ref": "F1EAD92DBE" + }, + "MetricsConfig": { + "Metrics": [] } } }, @@ -198,6 +201,11 @@ }, "FunctionName": { "Ref": "F23BAC7B9C" + }, + "MetricsConfig": { + "Metrics": [ + "EventCount" + ] } } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json index b4af7f5c51a98..b8b9edd78fa5e 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/manifest.json @@ -16,10 +16,9 @@ "templateFile": "lambda-event-source-metrics-config-sqs.template.json", "terminationProtection": false, "validateOnSynth": false, - "notificationArns": [], "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/669b2e4eff908108494ed2f1e907e26d006362dd15eeb24f75034b503c13ddaf.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/5d4025b6edf3c156b92b7e7cb9903ece5091d3b6ad4ddd4b70d00a4817b044a2.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -119,7 +118,6 @@ "templateFile": "lambdaeventsourcesqswithmetricsDefaultTestDeployAssert9B567B16.template.json", "terminationProtection": false, "validateOnSynth": false, - "notificationArns": [], "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json index fedb7152e8db1..0f4e6e1045f0a 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda-event-sources/test/integ.sqs-with-metrics-config.js.snapshot/tree.json @@ -162,6 +162,9 @@ }, "functionName": { "Ref": "F1EAD92DBE" + }, + "metricsConfig": { + "metrics": [] } } }, @@ -178,7 +181,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, @@ -358,6 +361,11 @@ }, "functionName": { "Ref": "F23BAC7B9C" + }, + "metricsConfig": { + "metrics": [ + "EventCount" + ] } } }, @@ -374,7 +382,7 @@ } }, "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.Function", + "fqn": "aws-cdk-lib.aws_lambda.FunctionBase", "version": "0.0.0" } }, From a8e0e1d8a92f8f8418020dfb4913c0f943d25a95 Mon Sep 17 00:00:00 2001 From: Roger Zhang Date: Wed, 20 Nov 2024 05:48:08 +0000 Subject: [PATCH 5/5] doc --- packages/aws-cdk-lib/aws-lambda/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/aws-cdk-lib/aws-lambda/README.md b/packages/aws-cdk-lib/aws-lambda/README.md index 4f979c367e526..3dab77d5c021d 100644 --- a/packages/aws-cdk-lib/aws-lambda/README.md +++ b/packages/aws-cdk-lib/aws-lambda/README.md @@ -861,7 +861,6 @@ The following code shows how to opt in for the enhanced metrics. ```ts import * as eventsources from 'aws-cdk-lib/aws-lambda-event-sources'; import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'; -import { MetricType } from 'aws-cdk-lib/aws-lambda-event-sources/lib'; declare const fn: lambda.Function; const table = new dynamodb.Table(this, 'Table', { @@ -875,7 +874,7 @@ const table = new dynamodb.Table(this, 'Table', { fn.addEventSource(new eventsources.DynamoEventSource(table, { startingPosition: lambda.StartingPosition.LATEST, metricsConfig: { - metrics: [MetricType.EVENT_COUNT], + metrics: [lambda.MetricType.EVENT_COUNT], } })); ```