Skip to content
v2.278.0

Runtime Class ​

Lambda function runtime environment.

If you need to use a runtime name that doesn't exist as a static member, you can instantiate a Runtime object, e.g: new Runtime('nodejs99.99').

For NodeJS lambda functions, it is recommended to use the latest LTS NodeJS runtime available (Runtime.NODEJS_LATEST) to keep the lambda function up-to-date.

Example ​

ts
const myFunctionHandler = new lambda.Function(this, 'MyFunction', {
  code: lambda.Code.fromAsset('resource/myfunction'),
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
});

const eventRule = cloudtrail.Trail.onEvent(this, 'MyCloudWatchEvent', {
  target: new targets.LambdaFunction(myFunctionHandler),
});

eventRule.addEventPattern({
  account: ['123456789012'],
  source: ['aws.s3'],
});
python
my_function_handler = lambda_.Function(self, "MyFunction",
    code=lambda_.Code.from_asset("resource/myfunction"),
    runtime=lambda_.Runtime.NODEJS_LATEST,
    handler="index.handler"
)

event_rule = cloudtrail.Trail.on_event(self, "MyCloudWatchEvent",
    target=targets.LambdaFunction(my_function_handler)
)

event_rule.add_event_pattern(
    account=["123456789012"],
    source=["aws.s3"]
)
java
Function myFunctionHandler = Function.Builder.create(this, "MyFunction")
        .code(Code.fromAsset("resource/myfunction"))
        .runtime(Runtime.NODEJS_LATEST)
        .handler("index.handler")
        .build();

Rule eventRule = Trail.onEvent(this, "MyCloudWatchEvent", OnEventOptions.builder()
        .target(new LambdaFunction(myFunctionHandler))
        .build());

eventRule.addEventPattern(EventPattern.builder()
        .account(List.of("123456789012"))
        .source(List.of("aws.s3"))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var myFunctionHandler = new Function(this, "MyFunction", new FunctionProps {
    Code = Code.FromAsset("resource/myfunction"),
    Runtime = Runtime.NODEJS_LATEST,
    Handler = "index.handler"
});

var eventRule = Trail.OnEvent(this, "MyCloudWatchEvent", new OnEventOptions {
    Target = new LambdaFunction(myFunctionHandler)
});

eventRule.AddEventPattern(new EventPattern {
    Account = new [] { "123456789012" },
    Source = new [] { "aws.s3" }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
myFunctionHandler := lambda.NewFunction(this, jsii.String("MyFunction"), &FunctionProps{
	Code: lambda.Code_FromAsset(jsii.String("resource/myfunction")),
	Runtime: lambda.Runtime_NODEJS_LATEST(),
	Handler: jsii.String("index.handler"),
})

eventRule := cloudtrail.Trail_OnEvent(this, jsii.String("MyCloudWatchEvent"), &OnEventOptions{
	Target: targets.NewLambdaFunction(myFunctionHandler),
})

eventRule.AddEventPattern(&EventPattern{
	Account: []*string{
		jsii.String("123456789012"),
	},
	Source: []*string{
		jsii.String("aws.s3"),
	},
})

Initializer ​

ts
new Runtime(name: string, family?: RuntimeFamily, props?: LambdaRuntimeProps)
python
Runtime(name: str, family: typing.Optional[RuntimeFamily] = None, props: typing.Optional[LambdaRuntimeProps] = None)
java
new Runtime(String name, RuntimeFamily family, LambdaRuntimeProps props)
csharp
new Runtime(string name, RuntimeFamily? family = null, LambdaRuntimeProps? props = null)
go
NewRuntime(Name *string, Family RuntimeFamily, Props LambdaRuntimeProps)

Properties ​

ALLRuntime[]ALLtyping.List[Runtime]ALLList<Runtime>ALLRuntime[]ALL*[]Runtime static #
A list of all known `Runtime`'s.
bundlingImageDockerImagebundling_imageDockerImagebundlingImageDockerImageBundlingImageDockerImageBundlingImageDockerImage #
The bundling Docker image for this runtime.
notes

Unless the runtime was created with the bundlingDockerImage prop of LambdaRuntimeProps, this is an untagged AWS SAM build image. Its contents can change independently of the AWS CDK version. To pin a specific image version when bundling with Code.fromAsset(), pass DockerImage.fromRegistry('<image>:<tag>') as bundling.image. Constructs that build their own bundling image on top of this runtime's image (for example NodejsFunction) do not run it directly; when bundling runs in Docker (for example with forceDockerBundling: true), pin the base image for them by creating a runtime with a pinned image, e.g. new Runtime('nodejs20.x', RuntimeFamily.NODEJS, &#123; supportsInlineCode: true, bundlingDockerImage: 'public.ecr.aws/sam/build-nodejs20.x:&lt;tag>' &#125;). Copy any other props the predefined runtime sets, such as supportsSnapStart, so that the custom runtime stays equivalent to it.

DOTNET_10RuntimeDOTNET_10RuntimeDOTNET_10RuntimeDOTNET_10RuntimeDOTNET_10Runtime static #
The .NET 10 runtime (dotnet10).
DOTNET_6RuntimeDOTNET_6RuntimeDOTNET_6RuntimeDOTNET_6RuntimeDOTNET_6Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET runtime.
DOTNET_8RuntimeDOTNET_8RuntimeDOTNET_8RuntimeDOTNET_8RuntimeDOTNET_8Runtime static #
The .NET 8 runtime (dotnet8).
DOTNET_9RuntimeDOTNET_9RuntimeDOTNET_9RuntimeDOTNET_9RuntimeDOTNET_9Runtime static #
The .NET 9 runtime (dotnet9).
DOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
DOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
DOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
DOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest .NET Core runtime.
familymay be undefinedRuntimeFamilyfamilymay be undefinedRuntimeFamilyfamilymay be undefinedRuntimeFamilyFamilymay be undefinedRuntimeFamilyFamilymay be undefinedRuntimeFamily #
The runtime family.
FROM_IMAGERuntimeFROM_IMAGERuntimeFROM_IMAGERuntimeFROM_IMAGERuntimeFROM_IMAGERuntime static #
A special runtime entry to be used when function is using a docker image.
GO_1_XRuntimeGO_1_XRuntimeGO_1_XRuntimeGO_1_XRuntimeGO_1_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the PROVIDED_AL2023 runtime.
isVariablebooleanis_variableboolisVariableBooleanIsVariableboolIsVariable*bool #
Enabled for runtime enums that always target the latest available.
JAVA_11RuntimeJAVA_11RuntimeJAVA_11RuntimeJAVA_11RuntimeJAVA_11Runtime static #
The Java 11 runtime (java11).
JAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023Runtime static #
The Java 11 AL2023 runtime (java11.al2023).
JAVA_17RuntimeJAVA_17RuntimeJAVA_17RuntimeJAVA_17RuntimeJAVA_17Runtime static #
The Java 17 runtime (java17).
JAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023Runtime static #
The Java 17 AL2023 runtime (java17.al2023).
JAVA_21RuntimeJAVA_21RuntimeJAVA_21RuntimeJAVA_21RuntimeJAVA_21Runtime static #
The Java 21 runtime (java21).
JAVA_25RuntimeJAVA_25RuntimeJAVA_25RuntimeJAVA_25RuntimeJAVA_25Runtime static #
The Java 25 runtime (java25).
JAVA_8RuntimeJAVA_8RuntimeJAVA_8RuntimeJAVA_8RuntimeJAVA_8Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Java runtime.
JAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023Runtime static #
The Java 8 AL2023 runtime (java8.al2023).
JAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntime static #
The Java 8 Corretto runtime (java8.al2).
namestringnamestrnameStringNamestringName*string #
The name of this runtime, as expected by the Lambda resource.
NODEJSRuntimeNODEJSRuntimeNODEJSRuntimeNODEJSRuntimeNODEJSRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_20_XRuntimeNODEJS_20_XRuntimeNODEJS_20_XRuntimeNODEJS_20_XRuntimeNODEJS_20_XRuntime static #
The NodeJS 20.x runtime (nodejs20.x).
NODEJS_22_XRuntimeNODEJS_22_XRuntimeNODEJS_22_XRuntimeNODEJS_22_XRuntimeNODEJS_22_XRuntime static #
The NodeJS 22.x runtime (nodejs22.x).
NODEJS_24_XRuntimeNODEJS_24_XRuntimeNODEJS_24_XRuntimeNODEJS_24_XRuntimeNODEJS_24_XRuntime static #
The NodeJS 24.x runtime (nodejs24.x).
NODEJS_26_XRuntimeNODEJS_26_XRuntimeNODEJS_26_XRuntimeNODEJS_26_XRuntimeNODEJS_26_XRuntime static #
The NodeJS 26.x runtime (nodejs26.x).
NODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest NodeJS runtime.
NODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntime static #
The latest NodeJS version currently available in ALL regions (not necessarily the latest NodeJS version available in YOUR region).
PROVIDEDRuntimePROVIDEDRuntimePROVIDEDRuntimePROVIDEDRuntimePROVIDEDRuntime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest provided.al2023 runtime.
PROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2Runtime static #
The custom provided runtime with Amazon Linux 2 (provided.al2).
PROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023Runtime static #
The custom provided runtime with Amazon Linux 2023 (provided.al2023).
PYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
PYTHON_3_10RuntimePYTHON_3_10RuntimePYTHON_3_10RuntimePYTHON_3_10RuntimePYTHON_3_10Runtime static #
The Python 3.10 runtime (python3.10).
PYTHON_3_11RuntimePYTHON_3_11RuntimePYTHON_3_11RuntimePYTHON_3_11RuntimePYTHON_3_11Runtime static #
The Python 3.11 runtime (python3.11).
PYTHON_3_12RuntimePYTHON_3_12RuntimePYTHON_3_12RuntimePYTHON_3_12RuntimePYTHON_3_12Runtime static #
The Python 3.12 runtime (python3.12).
PYTHON_3_13RuntimePYTHON_3_13RuntimePYTHON_3_13RuntimePYTHON_3_13RuntimePYTHON_3_13Runtime static #
The Python 3.13 runtime (python3.13).
PYTHON_3_14RuntimePYTHON_3_14RuntimePYTHON_3_14RuntimePYTHON_3_14RuntimePYTHON_3_14Runtime static #
The Python 3.14 runtime (python3.14).
PYTHON_3_15RuntimePYTHON_3_15RuntimePYTHON_3_15RuntimePYTHON_3_15RuntimePYTHON_3_15Runtime static #
The Python 3.15 runtime (python3.15).
PYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.

The Python 3.6 runtime is deprecated as of July 2022.

PYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
PYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
PYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Python runtime.
RUBY_2_5RuntimeRUBY_2_5RuntimeRUBY_2_5RuntimeRUBY_2_5RuntimeRUBY_2_5Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Ruby runtime.
RUBY_2_7RuntimeRUBY_2_7RuntimeRUBY_2_7RuntimeRUBY_2_7RuntimeRUBY_2_7Runtime static deprecated #
Legacy runtime no longer supported by AWS Lambda. Migrate to the latest Ruby runtime.
RUBY_3_2RuntimeRUBY_3_2RuntimeRUBY_3_2RuntimeRUBY_3_2RuntimeRUBY_3_2Runtime static #
The Ruby 3.2 runtime (ruby3.2).
RUBY_3_3RuntimeRUBY_3_3RuntimeRUBY_3_3RuntimeRUBY_3_3RuntimeRUBY_3_3Runtime static #
The Ruby 3.3 runtime (ruby3.3).
RUBY_3_4RuntimeRUBY_3_4RuntimeRUBY_3_4RuntimeRUBY_3_4RuntimeRUBY_3_4Runtime static #
The Ruby 3.4 runtime (ruby3.4).
RUBY_4_0RuntimeRUBY_4_0RuntimeRUBY_4_0RuntimeRUBY_4_0RuntimeRUBY_4_0Runtime static #
The Ruby 4.0 runtime (ruby4.0).
supportsCodeGuruProfilingbooleansupports_code_guru_profilingboolsupportsCodeGuruProfilingBooleanSupportsCodeGuruProfilingboolSupportsCodeGuruProfiling*bool #
Whether this runtime is integrated with and supported for profiling using Amazon CodeGuru Profiler.
supportsInlineCodebooleansupports_inline_codeboolsupportsInlineCodeBooleanSupportsInlineCodeboolSupportsInlineCode*bool #
Whether the ``ZipFile`` (aka inline code) property can be used with this runtime.
supportsSnapStartbooleansupports_snap_startboolsupportsSnapStartBooleanSupportsSnapStartboolSupportsSnapStart*bool #
Whether this runtime supports snapstart.

Methods ​

determineLatestPythonRuntime(scope: Construct): Runtime // chainable@staticmethod def determine_latest_python_runtime(scope: Construct) -> Runtimepublic static Runtime determineLatestPythonRuntime(Construct scope)public static Runtime DetermineLatestPythonRuntime(Construct scope)func DetermineLatestPythonRuntime(Scope Construct) Runtime static #
The latest Python version currently available.
runtimeEquals(other: Runtime): booleandef runtime_equals(self, other: Runtime) -> boolpublic Boolean runtimeEquals(Runtime other)public bool RuntimeEquals(Runtime other)func RuntimeEquals(Other Runtime) *bool #
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string #