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.
| CloudFormation | AWS::Lambda::Runtime |
|---|---|
| L1 type | CfnRuntime |
| Source | aws-lambda/lib/runtime.ts |
| Type last changed |
Example
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'],
});
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"]
)
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());
// 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" }
});
// 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
new Runtime(name: string, family?: RuntimeFamily, props?: LambdaRuntimeProps)
Runtime(name: str, family: typing.Optional[RuntimeFamily] = None, props: typing.Optional[LambdaRuntimeProps] = None)
new Runtime(String name, RuntimeFamily family, LambdaRuntimeProps props)
new Runtime(string name, RuntimeFamily? family = null, LambdaRuntimeProps? props = null)
NewRuntime(Name *string, Family RuntimeFamily, Props LambdaRuntimeProps)
Properties
bundlingImageDockerImagebundling_imageDockerImagebundlingImageDockerImageBundlingImageDockerImageBundlingImageDockerImage #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, { supportsInlineCode: true, bundlingDockerImage: 'public.ecr.aws/sam/build-nodejs20.x:<tag>' }). Copy any other props the predefined runtime sets, such as supportsSnapStart, so that the custom runtime stays equivalent to it.
DOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1RuntimeDOTNET_CORE_1Runtime static deprecated #DOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2RuntimeDOTNET_CORE_2Runtime static deprecated #DOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1RuntimeDOTNET_CORE_2_1Runtime static deprecated #DOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1RuntimeDOTNET_CORE_3_1Runtime static deprecated #familymay be undefinedRuntimeFamilyfamilymay be undefinedRuntimeFamilyfamilymay be undefinedRuntimeFamilyFamilymay be undefinedRuntimeFamilyFamilymay be undefinedRuntimeFamily #JAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023RuntimeJAVA_11_AL2023Runtime static #JAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023RuntimeJAVA_17_AL2023Runtime static #JAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023RuntimeJAVA_8_AL2023Runtime static #JAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntimeJAVA_8_CORRETTORuntime static #NODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntimeNODEJS_10_XRuntime static deprecated #NODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntimeNODEJS_12_XRuntime static deprecated #NODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntimeNODEJS_14_XRuntime static deprecated #NODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntimeNODEJS_16_XRuntime static deprecated #NODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntimeNODEJS_18_XRuntime static deprecated #NODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3RuntimeNODEJS_4_3Runtime static deprecated #NODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10RuntimeNODEJS_6_10Runtime static deprecated #NODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10RuntimeNODEJS_8_10Runtime static deprecated #NODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntimeNODEJS_LATESTRuntime static #PROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2RuntimePROVIDED_AL2Runtime static #PROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023RuntimePROVIDED_AL2023Runtime static #PYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7RuntimePYTHON_2_7Runtime static deprecated #PYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6RuntimePYTHON_3_6Runtime static deprecated #The Python 3.6 runtime is deprecated as of July 2022.
PYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7RuntimePYTHON_3_7Runtime static deprecated #PYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8RuntimePYTHON_3_8Runtime static deprecated #PYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9RuntimePYTHON_3_9Runtime static deprecated #supportsCodeGuruProfilingbooleansupports_code_guru_profilingboolsupportsCodeGuruProfilingBooleanSupportsCodeGuruProfilingboolSupportsCodeGuruProfiling*bool #supportsInlineCodebooleansupports_inline_codeboolsupportsInlineCodeBooleanSupportsInlineCodeboolSupportsInlineCode*bool #supportsSnapStartbooleansupports_snap_startboolsupportsSnapStartBooleanSupportsSnapStartboolSupportsSnapStart*bool #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 #toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string #