From b6fa9a2a62ae8c9ff80027f9846718dfc9b191d7 Mon Sep 17 00:00:00 2001 From: Marcio Cruz de Almeida <67694075+marciocadev@users.noreply.github.com> Date: Mon, 5 Dec 2022 19:10:43 -0300 Subject: [PATCH] feat(aws-lambda): Generates a version when currentVersionOptions is set (#23225) ## Description Specifying `currentVersionOptions` for a `Function` has no effect unless the `currentVersion` method is called. ## Solution when defining a `currentVersionOptions` a new version will be created automatically, without the need to execute `currentVersion` method. Fixes #23002 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-lambda/README.md | 19 +- packages/@aws-cdk/aws-lambda/lib/function.ts | 3 + .../@aws-cdk/aws-lambda/test/function.test.ts | 45 +++- ...efaultTestDeployAssertF66C8354.assets.json | 19 ++ ...aultTestDeployAssertF66C8354.template.json | 36 +++ .../cdk.out | 1 + .../current-version-options.assets.json | 19 ++ .../current-version-options.template.json | 99 ++++++++ .../integ.json | 12 + .../manifest.json | 123 ++++++++++ .../tree.json | 221 ++++++++++++++++++ .../test/integ.current-version-options.ts | 26 +++ 12 files changed, 610 insertions(+), 13 deletions(-) create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.template.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.assets.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.template.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/integ.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/tree.json create mode 100644 packages/@aws-cdk/aws-lambda/test/integ.current-version-options.ts diff --git a/packages/@aws-cdk/aws-lambda/README.md b/packages/@aws-cdk/aws-lambda/README.md index 7091fdce9c04d..419425f44f6a5 100644 --- a/packages/@aws-cdk/aws-lambda/README.md +++ b/packages/@aws-cdk/aws-lambda/README.md @@ -85,9 +85,9 @@ To deploy a `DockerImageFunction` on Lambda `arm64` architecture, specify `Archi This will bundle docker image assets for `arm64` architecture with `--platform linux/arm64` even if build within an `x86_64` host. ```ts -new DockerImageFunction(this, 'AssetFunction', { - code: DockerImageCode.fromImageAsset(path.join(__dirname, 'docker-arm64-handler')), - architecture: Architecture.ARM_64, +new lambda.DockerImageFunction(this, 'AssetFunction', { + code: lambda.DockerImageCode.fromImageAsset(path.join(__dirname, 'docker-arm64-handler')), + architecture: lambda.Architecture.ARM_64, }); ``` @@ -283,6 +283,19 @@ const version = new lambda.Version(this, 'MyVersion', { }); ``` +Or setting the `currentVersionOptions` when creating a new lambda + +```ts +new lambda.Function(this, 'MyVersionedLambda', { + runtime: lambda.Runtime.NODEJS_18_X, + handler: 'index.handler', + code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')), + currentVersionOptions: { + provisionedConcurrentExecutions: 3, + }, +}); +``` + The major caveat to know here is that a function version must always point to a specific 'version' of the function. When the function is modified, the version will continue to point to the 'then version' of the function. diff --git a/packages/@aws-cdk/aws-lambda/lib/function.ts b/packages/@aws-cdk/aws-lambda/lib/function.ts index 5da300546c576..0976b2962e7cf 100644 --- a/packages/@aws-cdk/aws-lambda/lib/function.ts +++ b/packages/@aws-cdk/aws-lambda/lib/function.ts @@ -858,6 +858,9 @@ export class Function extends FunctionBase { } this.currentVersionOptions = props.currentVersionOptions; + if (props.currentVersionOptions) { + this.currentVersion; + } if (props.filesystem) { if (!props.vpc) { diff --git a/packages/@aws-cdk/aws-lambda/test/function.test.ts b/packages/@aws-cdk/aws-lambda/test/function.test.ts index bad9a95ec8d4e..cd128a5050193 100644 --- a/packages/@aws-cdk/aws-lambda/test/function.test.ts +++ b/packages/@aws-cdk/aws-lambda/test/function.test.ts @@ -2871,7 +2871,7 @@ describe('function', () => { describe('FunctionUrl', () => { test('addFunctionUrl creates a function url with default options', () => { - // GIVEN + // GIVEN const stack = new cdk.Stack(); const fn = new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('hello()'), @@ -2895,7 +2895,7 @@ describe('function', () => { }); test('addFunctionUrl creates a function url with all options', () => { - // GIVEN + // GIVEN const stack = new cdk.Stack(); const fn = new lambda.Function(stack, 'MyLambda', { code: new lambda.InlineCode('hello()'), @@ -3045,6 +3045,31 @@ describe('function', () => { }, }); }); + + test('Generates a version when currentVersionOptions is set', () => { + const stack = new cdk.Stack(); + + new lambda.Function(stack, 'MyLambda', { + code: new lambda.InlineCode('foo'), + handler: 'index.handler', + runtime: lambda.Runtime.NODEJS_14_X, + currentVersionOptions: { + provisionedConcurrentExecutions: 3, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Version', { + ProvisionedConcurrencyConfig: { + ProvisionedConcurrentExecutions: 3, + }, + }); + + Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', { + Code: { ZipFile: 'foo' }, + Handler: 'index.handler', + Runtime: 'nodejs14.x', + }); + }); }); test('throws if ephemeral storage size is out of bound', () => { @@ -3141,14 +3166,14 @@ test('set SnapStart to desired value', () => { Template.fromStack(stack).hasResource('AWS::Lambda::Function', { Properties: - { - Code: { ZipFile: 'java11-test-function.zip' }, - Handler: 'example.Handler::handleRequest', - Runtime: 'java11', - SnapStart: { - ApplyOn: 'PublishedVersions', - }, - }, + { + Code: { ZipFile: 'java11-test-function.zip' }, + Handler: 'example.Handler::handleRequest', + Runtime: 'java11', + SnapStart: { + ApplyOn: 'PublishedVersions', + }, + }, }); }); diff --git a/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets.json new file mode 100644 index 0000000000000..944bb1b8ee642 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets.json @@ -0,0 +1,19 @@ +{ + "version": "22.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.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/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.template.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/CurrentVersionOptionsDefaultTestDeployAssertF66C8354.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/aws-lambda/test/integ.current-version-options.js.snapshot/cdk.out b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/cdk.out new file mode 100644 index 0000000000000..145739f539580 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"22.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.assets.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.assets.json new file mode 100644 index 0000000000000..22942b1c5c086 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.assets.json @@ -0,0 +1,19 @@ +{ + "version": "22.0.0", + "files": { + "a37f787b341d3d57968efec7be372be0c175afbeae09ab1909503e7a7f7dc6b8": { + "source": { + "path": "current-version-options.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "a37f787b341d3d57968efec7be372be0c175afbeae09ab1909503e7a7f7dc6b8.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/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.template.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.template.json new file mode 100644 index 0000000000000..9826778f6ba00 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/current-version-options.template.json @@ -0,0 +1,99 @@ +{ + "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" + ] + ] + } + ] + } + }, + "FC4345940": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "\n exports.handler = async(event) => {\n return \"My versioned lambda\";\n };\n " + }, + "Role": { + "Fn::GetAtt": [ + "FServiceRole3AC82EE1", + "Arn" + ] + }, + "Handler": "index.handler", + "Runtime": "nodejs14.x" + }, + "DependsOn": [ + "FServiceRole3AC82EE1" + ] + }, + "FCurrentVersion58B8A55Dc23085bc26dff8641d9434d378493303": { + "Type": "AWS::Lambda::Version", + "Properties": { + "FunctionName": { + "Ref": "FC4345940" + }, + "ProvisionedConcurrencyConfig": { + "ProvisionedConcurrentExecutions": 3 + } + } + } + }, + "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/aws-lambda/test/integ.current-version-options.js.snapshot/integ.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/integ.json new file mode 100644 index 0000000000000..7dda851e5ec00 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "22.0.0", + "testCases": { + "CurrentVersionOptions/DefaultTest": { + "stacks": [ + "current-version-options" + ], + "assertionStack": "CurrentVersionOptions/DefaultTest/DeployAssert", + "assertionStackName": "CurrentVersionOptionsDefaultTestDeployAssertF66C8354" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/manifest.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/manifest.json new file mode 100644 index 0000000000000..0358446afe01c --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/manifest.json @@ -0,0 +1,123 @@ +{ + "version": "22.0.0", + "artifacts": { + "current-version-options.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "current-version-options.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "current-version-options": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "current-version-options.template.json", + "validateOnSynth": false, + "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}/a37f787b341d3d57968efec7be372be0c175afbeae09ab1909503e7a7f7dc6b8.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "current-version-options.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": [ + "current-version-options.assets" + ], + "metadata": { + "/current-version-options/F/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FServiceRole3AC82EE1" + } + ], + "/current-version-options/F/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FC4345940" + } + ], + "/current-version-options/F/CurrentVersion/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "FCurrentVersion58B8A55Dc23085bc26dff8641d9434d378493303" + } + ], + "/current-version-options/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/current-version-options/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "current-version-options" + }, + "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "CurrentVersionOptionsDefaultTestDeployAssertF66C8354": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.template.json", + "validateOnSynth": false, + "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": [ + "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.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": [ + "CurrentVersionOptionsDefaultTestDeployAssertF66C8354.assets" + ], + "metadata": { + "/CurrentVersionOptions/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/CurrentVersionOptions/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "CurrentVersionOptions/DefaultTest/DeployAssert" + }, + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/tree.json b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/tree.json new file mode 100644 index 0000000000000..3c2b3b015cfbe --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.js.snapshot/tree.json @@ -0,0 +1,221 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "current-version-options": { + "id": "current-version-options", + "path": "current-version-options", + "children": { + "F": { + "id": "F", + "path": "current-version-options/F", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "current-version-options/F/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "current-version-options/F/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "@aws-cdk/core.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "current-version-options/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/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "current-version-options/F/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "\n exports.handler = async(event) => {\n return \"My versioned lambda\";\n };\n " + }, + "role": { + "Fn::GetAtt": [ + "FServiceRole3AC82EE1", + "Arn" + ] + }, + "handler": "index.handler", + "runtime": "nodejs14.x" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnFunction", + "version": "0.0.0" + } + }, + "CurrentVersion": { + "id": "CurrentVersion", + "path": "current-version-options/F/CurrentVersion", + "children": { + "Resource": { + "id": "Resource", + "path": "current-version-options/F/CurrentVersion/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Version", + "aws:cdk:cloudformation:props": { + "functionName": { + "Ref": "FC4345940" + }, + "provisionedConcurrencyConfig": { + "provisionedConcurrentExecutions": 3 + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.CfnVersion", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Version", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-lambda.Function", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "current-version-options/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "current-version-options/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "CurrentVersionOptions": { + "id": "CurrentVersionOptions", + "path": "CurrentVersionOptions", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "CurrentVersionOptions/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "CurrentVersionOptions/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.168" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "CurrentVersionOptions/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "CurrentVersionOptions/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "CurrentVersionOptions/DefaultTest/DeployAssert/CheckBootstrapVersion", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } + }, + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.168" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.ts b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.ts new file mode 100644 index 0000000000000..3f440150fe947 --- /dev/null +++ b/packages/@aws-cdk/aws-lambda/test/integ.current-version-options.ts @@ -0,0 +1,26 @@ +import * as cdk from '@aws-cdk/core'; +import * as integ from '@aws-cdk/integ-tests'; +import * as lambda from '../lib'; + +const app = new cdk.App(); + +const stack = new cdk.Stack(app, 'current-version-options'); + +new lambda.Function(stack, 'F', { + code: new lambda.InlineCode(` + exports.handler = async(event) => { + return "My versioned lambda"; + }; + `), + handler: 'index.handler', + runtime: lambda.Runtime.NODEJS_14_X, + currentVersionOptions: { + provisionedConcurrentExecutions: 3, + }, +}); + +new integ.IntegTest(app, 'CurrentVersionOptions', { + testCases: [stack], +}); + +app.synth(); \ No newline at end of file