Updating Lambda runtimes for resource types and hooks
Amazon CloudFormation resource types and hooks are developed using CloudFormation CLI language plug-ins available for Go, Java, Python, and TypeScript. The language plug-ins eventually need to be updated in order to maintain compatibility.
You can update your runtime by modifying parameters in the .rpdk-config and
template.yml files. These files are found in your resource provider or
hooks package. We recommend that your CloudFormation resource types and hooks use supported
Lambda
runtimes.
Upgrading the Java runtime
Steps to upgrade to Java 17
-
In the
.rpdk-configfile, change theruntimeparameter tojava17.The following is an example
.rpdk-configusing thejava17runtime:{ "typeName": "AWS::DirectoryService::SimpleAD", "language": "java", "runtime": "java17", "entrypoint": "software.amazon.directoryservice.simplead.HandlerWrapper::handleRequest", "testEntrypoint": "software.amazon.directoryservice.simplead.HandlerWrapper::testEntrypoint", "settings": { "namespace": [ "software", "amazon", "directoryservice", "simplead" ], "protocolVersion": "2.0.0" } } -
In the
template.ymlfile:-
In
TypeFunctionandTestEntrypoint, change theRuntimeparameters tojava17.
The following is an example
template.ymlfile using thejava17runtime:AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: AWS SAM template for the AWS::DirectoryService::SimpleAD resource type Globals: Function: Timeout: 180 # docker start-up times can be long for SAM CLI MemorySize: 1024 Resources: TypeFunction: Type: AWS::Serverless::Function Properties: Handler: software.amazon.directoryservice.simplead.HandlerWrapper::handleRequest Runtime: java17 CodeUri: ./target/aws-directoryservice-simplead-handler-1.0-SNAPSHOT.jar TestEntrypoint: Type: AWS::Serverless::Function Properties: Handler: software.amazon.directoryservice.simplead.HandlerWrapper::testEntrypoint Runtime: java17 CodeUri: ./target/aws-directoryservice-simplead-handler-1.0-SNAPSHOT.jar -
Upgrading the Go runtime
Steps to upgrade to provided.al2
-
In the
.rpdk-configfile:-
Change the
runtimeparameter toporovided.al2. -
Change
entrypointandtestEntrypointparamters tobootstrap.
The following is an example
.rpdk-configfile using theprovided.al2runtime:{ "typeName": "Example::GitHub::Repo", "language": "go", "runtime": "provided.al2", "entrypoint": "bootstrap", "testEntrypoint": "bootstrap", "settings": { "import_path": "github.com/aws-cloudformation/cloudformation-cli-go-plugin/examples/github-repo", "protocolVersion": "2.0.0", "pluginVersion": "2.0.0" } } -
-
In the template.yml file:
-
In
TypeFunctionandTestEntrypoint, change theRuntimeparameters toprovided.al2. -
In
TypeFunctionandTestEntrypoint, change theHandlerparameters tobootstrap. -
In
TypeFunctionandTestEntrypoint, addx86_64to theArchitectureparameter.
The following is an example
template.ymlfile using theprovided.al2runtime:AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: AWS SAM template for the Example::GitHub::Repo resource type Globals: Function: Timeout: 60 # docker start-up times can be long for SAM CLI Resources: TypeFunction: Type: AWS::Serverless::Function Metadata: BuildMethod: go1.x Properties: Handler: bootstrap Runtime: provided.al2 Architectures: - x86_64 CodeUri: bin/ # Uncomment to test with AWS resources # Environment: # Variables: # AWS_FORCE_INTEGRATIONS: "true" TestEntrypoint: Type: AWS::Serverless::Function Metadata: BuildMethod: go1.x Properties: Handler: bootstrap Runtime: provided.al2 Architectures: - x86_64 CodeUri: bin/ -
Upgrading the Python runtime
Steps to upgrade to Python 3.11
-
In the
.rpdk-configfile:-
Change the
runtimeparameter topython3.11. -
Change the
languageparameter topython311.
The following is an example
.rpdk-configfile using thepython3.11runtime:{ "artifact_type": "RESOURCE", "typeName": "AWS::EC2::Instance", "language": "python311", "runtime": "python3.11", "entrypoint": "aws_ec2_instance.handlers.resource", "testEntrypoint": "aws_ec2_instance.handlers.test_entrypoint", "settings": { "version": false, "subparser_name": null, "verbose": 0, "force": false, "type_name": null, "artifact_type": null, "endpoint_url": null, "region": null, "target_schemas": [], "profile": null, "use_docker": true, "no_docker": false, "protocolVersion": "2.0.0" } } -
-
In the
template.ymlfile:-
In
TypeFunctionandTestEntrypoint, change theRuntimeparameters topython3.11.
The following is an example
template.ymlfile using thepython3.11runtime:AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: AWS SAM template for the AWS::EC2::Instance resource type Globals: Function: Timeout: 180 # docker start-up times can be long for SAM CLI MemorySize: 256 Resources: TypeFunction: Type: AWS::Serverless::Function Properties: Handler: aws_ec2_instance.handlers.resource Runtime: python3.11 CodeUri: build/ TestEntrypoint: Type: AWS::Serverless::Function Properties: Handler: aws_ec2_instance.handlers.test_entrypoint Runtime: python3.11 CodeUri: build/ -
Upgrading the Node.js runtime
Steps to upgrade to Node.js 18
-
In the
.rpdk-configfile, change theruntimeparameter tonodejs18.x.{ "artifact_type": "RESOURCE", "typeName": "Dynatrace::Environment::Metric", "language": "typescript", "runtime": "nodejs18.x", "entrypoint": "dist/Dynatrace-Environment-Metric/src/handlers.entrypoint", "testEntrypoint": "dist/Dynatrace-Environment-Metric/src/handlers.testEntrypoint", "settings": { "version": false, "subparser_name": null, "verbose": 0, "force": false, "type_name": null, "artifact_type": null, "endpoint_url": null, "region": null, "target_schemas": [], "useDocker": false, "protocolVersion": "2.0.0" }, "contractSettings":{ "typeConfiguration": { "configuration": { "DynatraceAccess": { "Token": "{{resolve:ssm-secure:/cfn/dynatrace/token:1}}", "Endpoint": "{{resolve:ssm-secure:/cfn/dynatrace/endpoint:1}}" } }, "configurationAlias": "default" } } } -
In the
template.ymlfile:-
In
TestEntrypointandTypeFunction, change theRuntimeparameters tonodejs18.x.
The following is an example
template.ymlfile using thenodejs18.xruntime:AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Description: AWS SAM template for the Dynatrace::Environment::Metric resource type Globals: Function: Timeout: 180 # docker start-up times can be long for SAM CLI MemorySize: 256 Resources: TestEntrypoint: Type: AWS::Serverless::Function Properties: Handler: dist/Dynatrace-Environment-Metric/src/handlers.testEntrypoint Runtime: nodejs18.x CodeUri: ./ TypeFunction: Type: AWS::Serverless::Function Properties: Handler: dist/Dynatrace-Environment-Metric/src/handlers.entrypoint Runtime: nodejs18.x CodeUri: ./ -