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-config
file, change theruntime
parameter tojava17
.The following is an example
.rpdk-config
using thejava17
runtime:{ "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.yml
file:-
In
TypeFunction
andTestEntrypoint
, change theRuntime
parameters tojava17
.
The following is an example
template.yml
file using thejava17
runtime: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-config
file:-
Change the
runtime
parameter toporovided.al2
. -
Change
entrypoint
andtestEntrypoint
paramters tobootstrap
.
The following is an example
.rpdk-config
file using theprovided.al2
runtime:{ "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
TypeFunction
andTestEntrypoint
, change theRuntime
parameters toprovided.al2
. -
In
TypeFunction
andTestEntrypoint
, change theHandler
parameters tobootstrap
. -
In
TypeFunction
andTestEntrypoint
, addx86_64
to theArchitecture
parameter.
The following is an example
template.yml
file using theprovided.al2
runtime: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-config
file:-
Change the
runtime
parameter topython3.11
. -
Change the
language
parameter topython311
.
The following is an example
.rpdk-config
file using thepython3.11
runtime:{ "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.yml
file:-
In
TypeFunction
andTestEntrypoint
, change theRuntime
parameters topython3.11
.
The following is an example
template.yml
file using thepython3.11
runtime: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-config
file, change theruntime
parameter 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.yml
file:-
In
TestEntrypoint
andTypeFunction
, change theRuntime
parameters tonodejs18.x
.
The following is an example
template.yml
file using thenodejs18.x
runtime: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: ./
-