From 53f47133fd8ce1bfdd77eb81c197665006b35105 Mon Sep 17 00:00:00 2001 From: Leonardo Gama <51037424+Leo10Gama@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:05:40 -0800 Subject: [PATCH] feat(lambda): add supportsSnapStart config to dotnet8 and python 3.12 (#32112) ### Issue # (if applicable) N/A ### Description of changes This change adds supportsSnapStart as true to dotnet8. This change is needed as Lambda Runtimes team is working on launching Snapstart support for dotnet8. Original PR raised by @Beau-Gosse-dev ### Description of how you validated changes Verified the change is the same as Python and Java. In addition, added new integ test ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- .../handler.cs | 16 + ...04591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip | Bin 0 -> 236 bytes ...-cdk-lambda-runtime-management.assets.json | 45 ++ ...dk-lambda-runtime-management.template.json | 256 +++++++++ .../cdk.out | 1 + .../integ.json | 12 + ...efaultTestDeployAssertDE680AF3.assets.json | 19 + ...aultTestDeployAssertDE680AF3.template.json | 36 ++ .../manifest.json | 235 ++++++++ .../tree.json | 535 ++++++++++++++++++ .../aws-lambda/test/integ.lambda-snapstart.ts | 40 ++ packages/aws-cdk-lib/aws-lambda/README.md | 2 +- .../aws-cdk-lib/aws-lambda/lib/function.ts | 2 +- .../aws-cdk-lib/aws-lambda/lib/runtime.ts | 6 +- 14 files changed, 1202 insertions(+), 3 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6/handler.cs create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/cdk.out create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/integ.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.template.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/manifest.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/tree.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.ts diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6/handler.cs b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6/handler.cs new file mode 100644 index 0000000000000..5151f1ca92df6 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6/handler.cs @@ -0,0 +1,16 @@ +[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] + +namespace Handler; + +public class Function { + public Function() {} + + public async Task Handler(APIGatewayProxyRequest request) { + var id = request.PathParameters["id"]; + + return new APIGatewayProxyResponse { + StatusCode = (int)HttpStatusCode.OK, + Body = JsonSerializer.Serialize(databaseRecord) + }; + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/asset.a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip new file mode 100644 index 0000000000000000000000000000000000000000..eae53ec32da7ae41f34ca2ad18e5d75b4057561c GIT binary patch literal 236 zcmWIWW@Zs#U|`^2II{Ya&kY}@YBwOyA1ornkeQc~TA^1^85+XLz--X&A1&JLA6;6( z&A`Z_y{T7&`kL^=Qf literal 0 HcmV?d00001 diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.assets.json new file mode 100644 index 0000000000000..a5b1f7d2a1f72 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.assets.json @@ -0,0 +1,45 @@ +{ + "version": "38.0.1", + "files": { + "a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f": { + "source": { + "path": "asset.a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6": { + "source": { + "path": "asset.a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6", + "packaging": "zip" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6.zip", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + }, + "45c1527ff0ae033c7e2bb4fa9b83b353902213c7c73162bdfa055210d24bd9ef": { + "source": { + "path": "aws-cdk-lambda-runtime-management.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "45c1527ff0ae033c7e2bb4fa9b83b353902213c7c73162bdfa055210d24bd9ef.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/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.template.json new file mode 100644 index 0000000000000..2206177033117 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/aws-cdk-lambda-runtime-management.template.json @@ -0,0 +1,256 @@ +{ + "Resources": { + "JavaSnapstartLambdaServiceRole50CD4832": { + "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" + ] + ] + } + ] + } + }, + "JavaSnapstartLambdaB19F6BA4": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip" + }, + "Handler": "Handler", + "Role": { + "Fn::GetAtt": [ + "JavaSnapstartLambdaServiceRole50CD4832", + "Arn" + ] + }, + "Runtime": "java11", + "SnapStart": { + "ApplyOn": "PublishedVersions" + } + }, + "DependsOn": [ + "JavaSnapstartLambdaServiceRole50CD4832" + ] + }, + "Python312SnapstartLambdaServiceRole16F303C0": { + "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" + ] + ] + } + ] + } + }, + "Python312SnapstartLambdaB0C15475": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "pass" + }, + "Handler": "Handler", + "Role": { + "Fn::GetAtt": [ + "Python312SnapstartLambdaServiceRole16F303C0", + "Arn" + ] + }, + "Runtime": "python3.12", + "SnapStart": { + "ApplyOn": "PublishedVersions" + } + }, + "DependsOn": [ + "Python312SnapstartLambdaServiceRole16F303C0" + ] + }, + "Python313SnapstartLambdaServiceRoleC3989FBF": { + "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" + ] + ] + } + ] + } + }, + "Python313SnapstartLambda008EE7A4": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "ZipFile": "pass" + }, + "Handler": "Handler", + "Role": { + "Fn::GetAtt": [ + "Python313SnapstartLambdaServiceRoleC3989FBF", + "Arn" + ] + }, + "Runtime": "python3.13", + "SnapStart": { + "ApplyOn": "PublishedVersions" + } + }, + "DependsOn": [ + "Python313SnapstartLambdaServiceRoleC3989FBF" + ] + }, + "DotnetSnapstartLambdaServiceRole222A9244": { + "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" + ] + ] + } + ] + } + }, + "DotnetSnapstartLambda7DAEB52E": { + "Type": "AWS::Lambda::Function", + "Properties": { + "Code": { + "S3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "S3Key": "a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6.zip" + }, + "Handler": "Handler", + "Role": { + "Fn::GetAtt": [ + "DotnetSnapstartLambdaServiceRole222A9244", + "Arn" + ] + }, + "Runtime": "dotnet8", + "SnapStart": { + "ApplyOn": "PublishedVersions" + } + }, + "DependsOn": [ + "DotnetSnapstartLambdaServiceRole222A9244" + ] + } + }, + "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/test/integ.lambda-snapstart.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/cdk.out new file mode 100644 index 0000000000000..c6e612584e352 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.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/test/integ.lambda-snapstart.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/integ.json new file mode 100644 index 0000000000000..36508d44bf19f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "38.0.1", + "testCases": { + "lambda-runtime-management/DefaultTest": { + "stacks": [ + "aws-cdk-lambda-runtime-management" + ], + "assertionStack": "lambda-runtime-management/DefaultTest/DeployAssert", + "assertionStackName": "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets.json new file mode 100644 index 0000000000000..9fe7db35af272 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.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/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.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/test/integ.lambda-snapstart.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/manifest.json new file mode 100644 index 0000000000000..abfe86e0b6822 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/manifest.json @@ -0,0 +1,235 @@ +{ + "version": "38.0.1", + "artifacts": { + "aws-cdk-lambda-runtime-management.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "aws-cdk-lambda-runtime-management.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "aws-cdk-lambda-runtime-management": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "aws-cdk-lambda-runtime-management.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}/45c1527ff0ae033c7e2bb4fa9b83b353902213c7c73162bdfa055210d24bd9ef.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "aws-cdk-lambda-runtime-management.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": [ + "aws-cdk-lambda-runtime-management.assets" + ], + "metadata": { + "/aws-cdk-lambda-runtime-management/JavaSnapstartLambda": [ + { + "type": "aws:cdk:warning", + "data": "SnapStart only support published Lambda versions. Ignore if function already have published versions [ack: @aws-cdk/aws-lambda:snapStartRequirePublish]" + } + ], + "/aws-cdk-lambda-runtime-management/JavaSnapstartLambda/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "JavaSnapstartLambdaServiceRole50CD4832" + } + ], + "/aws-cdk-lambda-runtime-management/JavaSnapstartLambda/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "JavaSnapstartLambdaB19F6BA4" + } + ], + "/aws-cdk-lambda-runtime-management/Python312SnapstartLambda": [ + { + "type": "aws:cdk:warning", + "data": "SnapStart only support published Lambda versions. Ignore if function already have published versions [ack: @aws-cdk/aws-lambda:snapStartRequirePublish]" + } + ], + "/aws-cdk-lambda-runtime-management/Python312SnapstartLambda/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Python312SnapstartLambdaServiceRole16F303C0" + } + ], + "/aws-cdk-lambda-runtime-management/Python312SnapstartLambda/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Python312SnapstartLambdaB0C15475" + } + ], + "/aws-cdk-lambda-runtime-management/Python313SnapstartLambda": [ + { + "type": "aws:cdk:warning", + "data": "SnapStart only support published Lambda versions. Ignore if function already have published versions [ack: @aws-cdk/aws-lambda:snapStartRequirePublish]" + } + ], + "/aws-cdk-lambda-runtime-management/Python313SnapstartLambda/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Python313SnapstartLambdaServiceRoleC3989FBF" + } + ], + "/aws-cdk-lambda-runtime-management/Python313SnapstartLambda/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "Python313SnapstartLambda008EE7A4" + } + ], + "/aws-cdk-lambda-runtime-management/DotnetSnapstartLambda": [ + { + "type": "aws:cdk:warning", + "data": "SnapStart only support published Lambda versions. Ignore if function already have published versions [ack: @aws-cdk/aws-lambda:snapStartRequirePublish]" + } + ], + "/aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/ServiceRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "DotnetSnapstartLambdaServiceRole222A9244" + } + ], + "/aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "DotnetSnapstartLambda7DAEB52E" + } + ], + "/aws-cdk-lambda-runtime-management/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/aws-cdk-lambda-runtime-management/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ], + "PythonSnapstartLambdaServiceRole8EF8BB34": [ + { + "type": "aws:cdk:logicalId", + "data": "PythonSnapstartLambdaServiceRole8EF8BB34", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "PythonSnapstartLambdaC0CE7563": [ + { + "type": "aws:cdk:logicalId", + "data": "PythonSnapstartLambdaC0CE7563", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "Python13SnapstartLambdaServiceRole4FF7D1E9": [ + { + "type": "aws:cdk:logicalId", + "data": "Python13SnapstartLambdaServiceRole4FF7D1E9", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "Python13SnapstartLambdaF3D6F9F4": [ + { + "type": "aws:cdk:logicalId", + "data": "Python13SnapstartLambdaF3D6F9F4", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "Python11SnapstartLambdaServiceRoleA18C39FB": [ + { + "type": "aws:cdk:logicalId", + "data": "Python11SnapstartLambdaServiceRoleA18C39FB", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ], + "Python11SnapstartLambda8C62C534": [ + { + "type": "aws:cdk:logicalId", + "data": "Python11SnapstartLambda8C62C534", + "trace": [ + "!!DESTRUCTIVE_CHANGES: WILL_DESTROY" + ] + } + ] + }, + "displayName": "aws-cdk-lambda-runtime-management" + }, + "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.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": [ + "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.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": [ + "lambdaruntimemanagementDefaultTestDeployAssertDE680AF3.assets" + ], + "metadata": { + "/lambda-runtime-management/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-runtime-management/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-runtime-management/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/test/integ.lambda-snapstart.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/tree.json new file mode 100644 index 0000000000000..d57f3d53f14ca --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.js.snapshot/tree.json @@ -0,0 +1,535 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "aws-cdk-lambda-runtime-management": { + "id": "aws-cdk-lambda-runtime-management", + "path": "aws-cdk-lambda-runtime-management", + "children": { + "JavaSnapstartLambda": { + "id": "JavaSnapstartLambda", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/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" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Code": { + "id": "Code", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/Code", + "children": { + "Stage": { + "id": "Stage", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/Code/Stage", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/Code/AssetBucket", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/JavaSnapstartLambda/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "s3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "s3Key": "a37d3ef54c18e7738fe5dc008504591bd3b1f14c6a09ee91eac6d55f7ca5ba5f.zip" + }, + "handler": "Handler", + "role": { + "Fn::GetAtt": [ + "JavaSnapstartLambdaServiceRole50CD4832", + "Arn" + ] + }, + "runtime": "java11", + "snapStart": { + "applyOn": "PublishedVersions" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "Python312SnapstartLambda": { + "id": "Python312SnapstartLambda", + "path": "aws-cdk-lambda-runtime-management/Python312SnapstartLambda", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-management/Python312SnapstartLambda/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-management/Python312SnapstartLambda/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/Python312SnapstartLambda/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" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/Python312SnapstartLambda/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "pass" + }, + "handler": "Handler", + "role": { + "Fn::GetAtt": [ + "Python312SnapstartLambdaServiceRole16F303C0", + "Arn" + ] + }, + "runtime": "python3.12", + "snapStart": { + "applyOn": "PublishedVersions" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "Python313SnapstartLambda": { + "id": "Python313SnapstartLambda", + "path": "aws-cdk-lambda-runtime-management/Python313SnapstartLambda", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-management/Python313SnapstartLambda/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-management/Python313SnapstartLambda/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/Python313SnapstartLambda/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" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/Python313SnapstartLambda/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "zipFile": "pass" + }, + "handler": "Handler", + "role": { + "Fn::GetAtt": [ + "Python313SnapstartLambdaServiceRoleC3989FBF", + "Arn" + ] + }, + "runtime": "python3.13", + "snapStart": { + "applyOn": "PublishedVersions" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "DotnetSnapstartLambda": { + "id": "DotnetSnapstartLambda", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda", + "children": { + "ServiceRole": { + "id": "ServiceRole", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/ServiceRole", + "children": { + "ImportServiceRole": { + "id": "ImportServiceRole", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/ServiceRole/ImportServiceRole", + "constructInfo": { + "fqn": "aws-cdk-lib.Resource", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/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" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_iam.Role", + "version": "0.0.0" + } + }, + "Code": { + "id": "Code", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/Code", + "children": { + "Stage": { + "id": "Stage", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/Code/Stage", + "constructInfo": { + "fqn": "aws-cdk-lib.AssetStaging", + "version": "0.0.0" + } + }, + "AssetBucket": { + "id": "AssetBucket", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/Code/AssetBucket", + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3.BucketBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_s3_assets.Asset", + "version": "0.0.0" + } + }, + "Resource": { + "id": "Resource", + "path": "aws-cdk-lambda-runtime-management/DotnetSnapstartLambda/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Lambda::Function", + "aws:cdk:cloudformation:props": { + "code": { + "s3Bucket": { + "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" + }, + "s3Key": "a328343cb12aa16bf2c12bfa98f28509923cf8a0e9771cccbbe967d9e15c08f6.zip" + }, + "handler": "Handler", + "role": { + "Fn::GetAtt": [ + "DotnetSnapstartLambdaServiceRole222A9244", + "Arn" + ] + }, + "runtime": "dotnet8", + "snapStart": { + "applyOn": "PublishedVersions" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.aws_lambda.Function", + "version": "0.0.0" + } + }, + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "aws-cdk-lambda-runtime-management/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "aws-cdk-lambda-runtime-management/CheckBootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnRule", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.Stack", + "version": "0.0.0" + } + }, + "lambda-runtime-management": { + "id": "lambda-runtime-management", + "path": "lambda-runtime-management", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "lambda-runtime-management/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "lambda-runtime-management/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "lambda-runtime-management/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-runtime-management/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-runtime-management/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/test/integ.lambda-snapstart.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.ts new file mode 100644 index 0000000000000..5f3efde3f82e3 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.lambda-snapstart.ts @@ -0,0 +1,40 @@ +import { App, Stack } from 'aws-cdk-lib'; +import * as integ from '@aws-cdk/integ-tests-alpha'; +import * as path from 'path'; +import { Code, Function, Runtime, SnapStartConf } from 'aws-cdk-lib/aws-lambda'; + +const app = new App(); + +const stack = new Stack(app, 'aws-cdk-lambda-runtime-management'); + +new Function(stack, 'JavaSnapstartLambda', { + code: Code.fromAsset(path.join(__dirname, 'handler-snapstart.zip')), + handler: 'Handler', + runtime: Runtime.JAVA_11, + snapStart: SnapStartConf.ON_PUBLISHED_VERSIONS, +}); + +new Function(stack, 'Python312SnapstartLambda', { + code: Code.fromInline('pass'), + handler: 'Handler', + runtime: Runtime.PYTHON_3_12, + snapStart: SnapStartConf.ON_PUBLISHED_VERSIONS, +}); + +new Function(stack, 'Python313SnapstartLambda', { + code: Code.fromInline('pass'), + handler: 'Handler', + runtime: Runtime.PYTHON_3_13, + snapStart: SnapStartConf.ON_PUBLISHED_VERSIONS, +}); + +new Function(stack, 'DotnetSnapstartLambda', { + code: Code.fromAsset('dotnet-handler'), + handler: 'Handler', + runtime: Runtime.DOTNET_8, + snapStart: SnapStartConf.ON_PUBLISHED_VERSIONS, +}); + +new integ.IntegTest(app, 'lambda-runtime-management', { + testCases: [stack], +}); diff --git a/packages/aws-cdk-lib/aws-lambda/README.md b/packages/aws-cdk-lib/aws-lambda/README.md index d3d1be7843c0b..02fc358c4b38e 100644 --- a/packages/aws-cdk-lib/aws-lambda/README.md +++ b/packages/aws-cdk-lib/aws-lambda/README.md @@ -1038,7 +1038,7 @@ https://docs.aws.amazon.com/lambda/latest/dg/invocation-recursion.html ## Lambda with SnapStart -SnapStart is currently supported only on Java 11 and later [Java managed runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). SnapStart does not support provisioned concurrency, Amazon Elastic File System (Amazon EFS), or ephemeral storage greater than 512 MB. After you enable Lambda SnapStart for a particular Lambda function, publishing a new version of the function will trigger an optimization process. +SnapStart is currently supported on Python 3.12, Python 3.13, .NET 8, and Java 11 and later [Java managed runtimes](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html). SnapStart does not support provisioned concurrency, Amazon Elastic File System (Amazon EFS), or ephemeral storage greater than 512 MB. After you enable Lambda SnapStart for a particular Lambda function, publishing a new version of the function will trigger an optimization process. See [the AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) to learn more about AWS Lambda SnapStart diff --git a/packages/aws-cdk-lib/aws-lambda/lib/function.ts b/packages/aws-cdk-lib/aws-lambda/lib/function.ts index fffdb6ae11ae6..38481f883b92e 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/function.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/function.ts @@ -354,7 +354,7 @@ export interface FunctionOptions extends EventInvokeConfigOptions { /** * Enable SnapStart for Lambda Function. - * SnapStart is currently supported only for Java 11, 17 runtime + * SnapStart is currently supported for Java 11, Java 17, Python 3.12, Python 3.13, and .NET 8 runtime * * @default - No snapstart */ diff --git a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts index aba6fde8249dd..72da4b88b60c5 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts @@ -183,6 +183,7 @@ export class Runtime { public static readonly PYTHON_3_12 = new Runtime('python3.12', RuntimeFamily.PYTHON, { supportsInlineCode: true, supportsCodeGuruProfiling: true, + supportsSnapStart: true, }); /** @@ -191,6 +192,7 @@ export class Runtime { public static readonly PYTHON_3_13 = new Runtime('python3.13', RuntimeFamily.PYTHON, { supportsInlineCode: true, supportsCodeGuruProfiling: true, + supportsSnapStart: true, }); /** @@ -240,7 +242,9 @@ export class Runtime { /** * The .NET 8 runtime (dotnet8) */ - public static readonly DOTNET_8 = new Runtime('dotnet8', RuntimeFamily.DOTNET_CORE); + public static readonly DOTNET_8 = new Runtime('dotnet8', RuntimeFamily.DOTNET_CORE, { + supportsSnapStart: true, + }); /** * The .NET Core 1.0 runtime (dotnetcore1.0)