From e0ebcfe8821d97788356798512a5c4e1e508cd7c Mon Sep 17 00:00:00 2001 From: Vandita Patidar Date: Thu, 7 Nov 2024 21:05:50 -0800 Subject: [PATCH] feat(lambda): add Python 3.13 runtime (#32054) ### Issue # (if applicable) NA ### Reason for this change Adds Python 3.13 to the available [Lambda Runtimes constants](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.Runtime.html#initializer) ### Description of how you validated changes Have added integration tests to validate the runtime support ### Checklist - [ ] 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* --- ...-cdk-lambda-runtime-inlinecode.assets.json | 6 +- ...dk-lambda-runtime-inlinecode.template.json | 126 +------- .../cdk.out | 2 +- .../integ.json | 12 +- ...efaultTestDeployAssert2C40D679.assets.json | 19 ++ ...aultTestDeployAssert2C40D679.template.json | 36 +++ .../manifest.json | 102 ++++--- .../tree.json | 280 +++++------------- .../test/integ.runtime.inlinecode.ts | 27 +- .../aws-cdk-lib/aws-lambda/lib/runtime.ts | 8 + 10 files changed, 214 insertions(+), 404 deletions(-) create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets.json create mode 100644 packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.template.json diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json index 43954191c1505..c7d5de3447f75 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.assets.json @@ -1,7 +1,7 @@ { - "version": "35.0.0", + "version": "38.0.1", "files": { - "0ebdc1ee0464a9de6deeef53b9dbfd33c32c14683b2f1c557bb194eaf4808018": { + "0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b": { "source": { "path": "aws-cdk-lambda-runtime-inlinecode.template.json", "packaging": "file" @@ -9,7 +9,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "0ebdc1ee0464a9de6deeef53b9dbfd33c32c14683b2f1c557bb194eaf4808018.json", + "objectKey": "0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b.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/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json index 974dac560fff4..80ff8a858dabc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/aws-cdk-lambda-runtime-inlinecode.template.json @@ -1,55 +1,5 @@ { "Resources": { - "PYTHON37ServiceRoleDE7E561E": { - "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" - ] - ] - } - ] - } - }, - "PYTHON37D3A10E04": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "def handler(event, context):\n return \"success\"" - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "PYTHON37ServiceRoleDE7E561E", - "Arn" - ] - }, - "Runtime": "python3.7" - }, - "DependsOn": [ - "PYTHON37ServiceRoleDE7E561E" - ] - }, "PYTHON38ServiceRole3EA86BBE": { "Type": "AWS::IAM::Role", "Properties": { @@ -250,57 +200,7 @@ "PYTHON312ServiceRoleBEB03378" ] }, - "NODEJS14XServiceRole4523ECDB": { - "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" - ] - ] - } - ] - } - }, - "NODEJS14X930214A3": { - "Type": "AWS::Lambda::Function", - "Properties": { - "Code": { - "ZipFile": "exports.handler = async function(event) { return \"success\" }" - }, - "Handler": "index.handler", - "Role": { - "Fn::GetAtt": [ - "NODEJS14XServiceRole4523ECDB", - "Arn" - ] - }, - "Runtime": "nodejs14.x" - }, - "DependsOn": [ - "NODEJS14XServiceRole4523ECDB" - ] - }, - "NODEJS16XServiceRoleB9DAFDFD": { + "PYTHON313ServiceRole907582AC": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { @@ -331,23 +231,23 @@ ] } }, - "NODEJS16XDE5DD82D": { + "PYTHON3136F4F65AE": { "Type": "AWS::Lambda::Function", "Properties": { "Code": { - "ZipFile": "exports.handler = async function(event) { return \"success\" }" + "ZipFile": "def handler(event, context):\n return \"success\"" }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ - "NODEJS16XServiceRoleB9DAFDFD", + "PYTHON313ServiceRole907582AC", "Arn" ] }, - "Runtime": "nodejs16.x" + "Runtime": "python3.13" }, "DependsOn": [ - "NODEJS16XServiceRoleB9DAFDFD" + "PYTHON313ServiceRole907582AC" ] }, "NODEJS18XServiceRole4D18036A": { @@ -452,11 +352,6 @@ } }, "Outputs": { - "PYTHON37functionName": { - "Value": { - "Ref": "PYTHON37D3A10E04" - } - }, "PYTHON38functionName": { "Value": { "Ref": "PYTHON38A180AE47" @@ -477,14 +372,9 @@ "Ref": "PYTHON3127B62731D" } }, - "NODEJS14XfunctionName": { - "Value": { - "Ref": "NODEJS14X930214A3" - } - }, - "NODEJS16XfunctionName": { + "PYTHON313functionName": { "Value": { - "Ref": "NODEJS16XDE5DD82D" + "Ref": "PYTHON3136F4F65AE" } }, "NODEJS18XfunctionName": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out index c5cb2e5de6344..c6e612584e352 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"35.0.0"} \ No newline at end of file +{"version":"38.0.1"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json index f28570670e559..454d46b766839 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/integ.json @@ -1,14 +1,12 @@ { - "version": "35.0.0", + "version": "38.0.1", "testCases": { - "integ.runtime.inlinecode": { + "lambda-runtime-inlinecode/DefaultTest": { "stacks": [ "aws-cdk-lambda-runtime-inlinecode" ], - "diffAssets": false, - "stackUpdateWorkflow": true + "assertionStack": "lambda-runtime-inlinecode/DefaultTest/DeployAssert", + "assertionStackName": "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679" } - }, - "synthContext": {}, - "enableLookups": false + } } \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets.json new file mode 100644 index 0000000000000..d6493d12e4ce7 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets.json @@ -0,0 +1,19 @@ +{ + "version": "38.0.1", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.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.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.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.runtime.inlinecode.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json index 78a68f141b23c..e6bd9b0e6ba7f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "35.0.0", + "version": "38.0.1", "artifacts": { "aws-cdk-lambda-runtime-inlinecode.assets": { "type": "cdk:asset-manifest", @@ -16,9 +16,10 @@ "templateFile": "aws-cdk-lambda-runtime-inlinecode.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}/0ebdc1ee0464a9de6deeef53b9dbfd33c32c14683b2f1c557bb194eaf4808018.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/0d74b5a40240d8fe0a138cb28488a1136484e5a20037fc9a6f57fd6f4426bd7b.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -34,24 +35,6 @@ "aws-cdk-lambda-runtime-inlinecode.assets" ], "metadata": { - "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "PYTHON37ServiceRoleDE7E561E" - } - ], - "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "PYTHON37D3A10E04" - } - ], - "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7-functionName": [ - { - "type": "aws:cdk:logicalId", - "data": "PYTHON37functionName" - } - ], "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_8/ServiceRole/Resource": [ { "type": "aws:cdk:logicalId", @@ -124,40 +107,22 @@ "data": "PYTHON312functionName" } ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/ServiceRole/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "NODEJS14XServiceRole4523ECDB" - } - ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/Resource": [ + "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/ServiceRole/Resource": [ { "type": "aws:cdk:logicalId", - "data": "NODEJS14X930214A3" + "data": "PYTHON313ServiceRole907582AC" } ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X-functionName": [ + "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/Resource": [ { "type": "aws:cdk:logicalId", - "data": "NODEJS14XfunctionName" + "data": "PYTHON3136F4F65AE" } ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/ServiceRole/Resource": [ + "/aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13-functionName": [ { "type": "aws:cdk:logicalId", - "data": "NODEJS16XServiceRoleB9DAFDFD" - } - ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/Resource": [ - { - "type": "aws:cdk:logicalId", - "data": "NODEJS16XDE5DD82D" - } - ], - "/aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X-functionName": [ - { - "type": "aws:cdk:logicalId", - "data": "NODEJS16XfunctionName" + "data": "PYTHON313functionName" } ], "/aws-cdk-lambda-runtime-inlinecode/NODEJS_18_X/ServiceRole/Resource": [ @@ -211,6 +176,55 @@ }, "displayName": "aws-cdk-lambda-runtime-inlinecode" }, + "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.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": [ + "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.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": [ + "lambdaruntimeinlinecodeDefaultTestDeployAssert2C40D679.assets" + ], + "metadata": { + "/lambda-runtime-inlinecode/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/lambda-runtime-inlinecode/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "lambda-runtime-inlinecode/DefaultTest/DeployAssert" + }, "Tree": { "type": "cdk:tree", "properties": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json index faeba4a2d4d21..cba00605f33f4 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.js.snapshot/tree.json @@ -8,105 +8,6 @@ "id": "aws-cdk-lambda-runtime-inlinecode", "path": "aws-cdk-lambda-runtime-inlinecode", "children": { - "PYTHON_3_7": { - "id": "PYTHON_3_7", - "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7/ServiceRole", - "children": { - "ImportServiceRole": { - "id": "ImportServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7/ServiceRole/ImportServiceRole", - "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7/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-inlinecode/PYTHON_3_7/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "def handler(event, context):\n return \"success\"" - }, - "handler": "index.handler", - "role": { - "Fn::GetAtt": [ - "PYTHON37ServiceRoleDE7E561E", - "Arn" - ] - }, - "runtime": "python3.7" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.Function", - "version": "0.0.0" - } - }, - "PYTHON_3_7-functionName": { - "id": "PYTHON_3_7-functionName", - "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_7-functionName", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, "PYTHON_3_8": { "id": "PYTHON_3_8", "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_8", @@ -503,17 +404,17 @@ "version": "0.0.0" } }, - "NODEJS_14_X": { - "id": "NODEJS_14_X", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X", + "PYTHON_3_13": { + "id": "PYTHON_3_13", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13", "children": { "ServiceRole": { "id": "ServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/ServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/ServiceRole", "children": { "ImportServiceRole": { "id": "ImportServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/ServiceRole/ImportServiceRole", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/ServiceRole/ImportServiceRole", "constructInfo": { "fqn": "aws-cdk-lib.Resource", "version": "0.0.0" @@ -521,7 +422,7 @@ }, "Resource": { "id": "Resource", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/ServiceRole/Resource", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/ServiceRole/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::IAM::Role", "aws:cdk:cloudformation:props": { @@ -566,120 +467,21 @@ }, "Resource": { "id": "Resource", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X/Resource", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13/Resource", "attributes": { "aws:cdk:cloudformation:type": "AWS::Lambda::Function", "aws:cdk:cloudformation:props": { "code": { - "zipFile": "exports.handler = async function(event) { return \"success\" }" - }, - "handler": "index.handler", - "role": { - "Fn::GetAtt": [ - "NODEJS14XServiceRole4523ECDB", - "Arn" - ] - }, - "runtime": "nodejs14.x" - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.CfnFunction", - "version": "0.0.0" - } - } - }, - "constructInfo": { - "fqn": "aws-cdk-lib.aws_lambda.Function", - "version": "0.0.0" - } - }, - "NODEJS_14_X-functionName": { - "id": "NODEJS_14_X-functionName", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_14_X-functionName", - "constructInfo": { - "fqn": "aws-cdk-lib.CfnOutput", - "version": "0.0.0" - } - }, - "NODEJS_16_X": { - "id": "NODEJS_16_X", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X", - "children": { - "ServiceRole": { - "id": "ServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/ServiceRole", - "children": { - "ImportServiceRole": { - "id": "ImportServiceRole", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/ServiceRole/ImportServiceRole", - "constructInfo": { - "fqn": "aws-cdk-lib.Resource", - "version": "0.0.0" - } - }, - "Resource": { - "id": "Resource", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X/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-inlinecode/NODEJS_16_X/Resource", - "attributes": { - "aws:cdk:cloudformation:type": "AWS::Lambda::Function", - "aws:cdk:cloudformation:props": { - "code": { - "zipFile": "exports.handler = async function(event) { return \"success\" }" + "zipFile": "def handler(event, context):\n return \"success\"" }, "handler": "index.handler", "role": { "Fn::GetAtt": [ - "NODEJS16XServiceRoleB9DAFDFD", + "PYTHON313ServiceRole907582AC", "Arn" ] }, - "runtime": "nodejs16.x" + "runtime": "python3.13" } }, "constructInfo": { @@ -693,9 +495,9 @@ "version": "0.0.0" } }, - "NODEJS_16_X-functionName": { - "id": "NODEJS_16_X-functionName", - "path": "aws-cdk-lambda-runtime-inlinecode/NODEJS_16_X-functionName", + "PYTHON_3_13-functionName": { + "id": "PYTHON_3_13-functionName", + "path": "aws-cdk-lambda-runtime-inlinecode/PYTHON_3_13-functionName", "constructInfo": { "fqn": "aws-cdk-lib.CfnOutput", "version": "0.0.0" @@ -921,12 +723,66 @@ "version": "0.0.0" } }, + "lambda-runtime-inlinecode": { + "id": "lambda-runtime-inlinecode", + "path": "lambda-runtime-inlinecode", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "lambda-runtime-inlinecode/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "lambda-runtime-inlinecode/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.4.2" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "lambda-runtime-inlinecode/DefaultTest/DeployAssert", + "children": { + "BootstrapVersion": { + "id": "BootstrapVersion", + "path": "lambda-runtime-inlinecode/DefaultTest/DeployAssert/BootstrapVersion", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnParameter", + "version": "0.0.0" + } + }, + "CheckBootstrapVersion": { + "id": "CheckBootstrapVersion", + "path": "lambda-runtime-inlinecode/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.3.0" + "version": "10.4.2" } } }, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts index 3411babefaaeb..3e7c206a3087d 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-lambda/test/integ.runtime.inlinecode.ts @@ -1,5 +1,6 @@ import { App, CfnOutput, Stack } from 'aws-cdk-lib'; import { Function, InlineCode, Runtime } from 'aws-cdk-lib/aws-lambda'; +import * as integ from '@aws-cdk/integ-tests-alpha'; // CloudFormation supports InlineCode only for a subset of runtimes. This integration test // is used to verify that the ones marked in the CDK are in fact supported by CloudFormation. @@ -15,13 +16,6 @@ const app = new App(); const stack = new Stack(app, 'aws-cdk-lambda-runtime-inlinecode'); -const python37 = new Function(stack, 'PYTHON_3_7', { - code: new InlineCode('def handler(event, context):\n return "success"'), - handler: 'index.handler', - runtime: Runtime.PYTHON_3_7, -}); -new CfnOutput(stack, 'PYTHON_3_7-functionName', { value: python37.functionName }); - const python38 = new Function(stack, 'PYTHON_3_8', { code: new InlineCode('def handler(event, context):\n return "success"'), handler: 'index.handler', @@ -50,19 +44,12 @@ const python312 = new Function(stack, 'PYTHON_3_12', { }); new CfnOutput(stack, 'PYTHON_3_12-functionName', { value: python312.functionName }); -const node14xfn = new Function(stack, 'NODEJS_14_X', { - code: new InlineCode('exports.handler = async function(event) { return "success" }'), - handler: 'index.handler', - runtime: Runtime.NODEJS_14_X, -}); -new CfnOutput(stack, 'NODEJS_14_X-functionName', { value: node14xfn.functionName }); - -const node16xfn = new Function(stack, 'NODEJS_16_X', { - code: new InlineCode('exports.handler = async function(event) { return "success" }'), +const python313 = new Function(stack, 'PYTHON_3_13', { + code: new InlineCode('def handler(event, context):\n return "success"'), handler: 'index.handler', - runtime: Runtime.NODEJS_16_X, + runtime: Runtime.PYTHON_3_13, }); -new CfnOutput(stack, 'NODEJS_16_X-functionName', { value: node16xfn.functionName }); +new CfnOutput(stack, 'PYTHON_3_13-functionName', { value: python313.functionName }); const node18xfn = new Function(stack, 'NODEJS_18_X', { code: new InlineCode('exports.handler = async function(event) { return "success" }'), @@ -78,4 +65,6 @@ const node20xfn = new Function(stack, 'NODEJS_20_X', { }); new CfnOutput(stack, 'NODEJS_20_X-functionName', { value: node20xfn.functionName }); -app.synth(); +new integ.IntegTest(app, 'lambda-runtime-inlinecode', { + testCases: [stack], +}); diff --git a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts index 4ffb89f35b2d4..aba6fde8249dd 100644 --- a/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts +++ b/packages/aws-cdk-lib/aws-lambda/lib/runtime.ts @@ -185,6 +185,14 @@ export class Runtime { supportsCodeGuruProfiling: true, }); + /** + * The Python 3.13 runtime (python3.13) + */ + public static readonly PYTHON_3_13 = new Runtime('python3.13', RuntimeFamily.PYTHON, { + supportsInlineCode: true, + supportsCodeGuruProfiling: true, + }); + /** * The Java 8 runtime (java8) * @deprecated Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Java runtime.