CfnFunction L1 construct
The AWS::Lambda::Function resource creates a Lambda function.
To create a function, you need a deployment package and an execution role . The deployment package is a .zip file archive or container image that contains your function code. The execution role grants the function permission to use AWS services, such as Amazon CloudWatch Logs for log streaming and AWS X-Ray for request tracing.
You set the package type to Image if the deployment package is a container image . For these functions, include the URI of the container image in the Amazon ECR registry in the ImageUri property of the Code property . You do not need to specify the handler and runtime properties.
You set the package type to Zip if the deployment package is a .zip file archive . For these functions, specify the Amazon S3 location of your .zip file in the Code property. Alternatively, for Node.js and Python functions, you can define your function inline in the ZipFile property of the Code property . In both cases, you must also specify the handler and runtime properties.
You can use code signing if your deployment package is a .zip file archive. To enable code signing for this function, specify the ARN of a code-signing configuration. When a user attempts to deploy a code package with UpdateFunctionCode , Lambda checks that the code package has a valid signature from a trusted publisher. The code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
When you update a AWS::Lambda::Function resource, CloudFormation calls the UpdateFunctionConfiguration and UpdateFunctionCode Lambda APIs under the hood. Because these calls happen sequentially, and invocations can happen between these calls, your function may encounter errors in the time between the calls. For example, if you remove an environment variable, and the code that references that environment variable in the same CloudFormation update, you may see invocation errors related to a missing environment variable. To work around this, you can invoke your function against a version or alias by default, rather than the $LATEST version.
Note that you configure provisioned concurrency on a AWS::Lambda::Version or a AWS::Lambda::Alias .
For a complete introduction to Lambda functions, see What is Lambda? in the Lambda developer guide.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lambda as lambda } from 'aws-cdk-lib';
const cfnFunction = new lambda.CfnFunction(this, 'MyCfnFunction', {
code: {
imageUri: 'imageUri',
s3Bucket: 's3Bucket',
s3Key: 's3Key',
s3ObjectStorageMode: 's3ObjectStorageMode',
s3ObjectVersion: 's3ObjectVersion',
sourceKmsKeyArn: 'sourceKmsKeyArn',
zipFile: 'zipFile',
},
role: 'role',
// the properties below are optional
architectures: ['architectures'],
capacityProviderConfig: {
lambdaManagedInstancesCapacityProviderConfig: {
capacityProviderArn: 'capacityProviderArn',
// the properties below are optional
executionEnvironmentMemoryGiBPerVCpu: 123,
perExecutionEnvironmentMaxConcurrency: 123,
},
},
codeSigningConfigArn: 'codeSigningConfigArn',
deadLetterConfig: {
targetArn: 'targetArn',
},
description: 'description',
durableConfig: {
executionTimeout: 123,
// the properties below are optional
kmsKeyArn: 'kmsKeyArn',
retentionPeriodInDays: 123,
},
environment: {
variables: {
variablesKey: 'variables',
},
},
ephemeralStorage: {
size: 123,
},
fileSystemConfigs: [{
arn: 'arn',
localMountPath: 'localMountPath',
// the properties below are optional
s3FilesConfig: {
directS3Read: 'directS3Read',
},
}],
functionName: 'functionName',
functionScalingConfig: {
maxExecutionEnvironments: 123,
minExecutionEnvironments: 123,
},
handler: 'handler',
imageConfig: {
command: ['command'],
entryPoint: ['entryPoint'],
workingDirectory: 'workingDirectory',
},
kmsKeyArn: 'kmsKeyArn',
layers: ['layers'],
loggingConfig: {
applicationLogLevel: 'applicationLogLevel',
logFormat: 'logFormat',
logGroup: 'logGroup',
systemLogLevel: 'systemLogLevel',
},
memorySize: 123,
packageType: 'packageType',
publishToLatestPublished: false,
recursiveLoop: 'recursiveLoop',
reservedConcurrentExecutions: 123,
runtime: 'runtime',
runtimeManagementConfig: {
updateRuntimeOn: 'updateRuntimeOn',
// the properties below are optional
runtimeVersionArn: 'runtimeVersionArn',
},
snapStart: {
applyOn: 'applyOn',
},
tags: [{
key: 'key',
value: 'value',
}],
tenancyConfig: {
tenantIsolationMode: 'tenantIsolationMode',
},
timeout: 123,
tracingConfig: {
mode: 'mode',
},
vpcConfig: {
ipv6AllowedForDualStack: false,
securityGroupIds: ['securityGroupIds'],
subnetIds: ['subnetIds'],
},
});
from aws_cdk import CfnTag
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_lambda as lambda_
cfn_function = lambda_.CfnFunction(self, "MyCfnFunction",
code=lambda.CfnFunction.CodeProperty(
image_uri="imageUri",
s3_bucket="s3Bucket",
s3_key="s3Key",
s3_object_storage_mode="s3ObjectStorageMode",
s3_object_version="s3ObjectVersion",
source_kms_key_arn="sourceKmsKeyArn",
zip_file="zipFile"
),
role="role",
# the properties below are optional
architectures=["architectures"],
capacity_provider_config=lambda.CfnFunction.CapacityProviderConfigProperty(
lambda_managed_instances_capacity_provider_config=lambda.CfnFunction.LambdaManagedInstancesCapacityProviderConfigProperty(
capacity_provider_arn="capacityProviderArn",
# the properties below are optional
execution_environment_memory_gi_b_per_v_cpu=123,
per_execution_environment_max_concurrency=123
)
),
code_signing_config_arn="codeSigningConfigArn",
dead_letter_config=lambda.CfnFunction.DeadLetterConfigProperty(
target_arn="targetArn"
),
description="description",
durable_config=lambda.CfnFunction.DurableConfigProperty(
execution_timeout=123,
# the properties below are optional
kms_key_arn="kmsKeyArn",
retention_period_in_days=123
),
environment=lambda.CfnFunction.EnvironmentProperty(
variables={
"variables_key": "variables"
}
),
ephemeral_storage=lambda.CfnFunction.EphemeralStorageProperty(
size=123
),
file_system_configs=[lambda.CfnFunction.FileSystemConfigProperty(
arn="arn",
local_mount_path="localMountPath",
# the properties below are optional
s3_files_config=lambda.CfnFunction.S3FilesConfigProperty(
direct_s3_read="directS3Read"
)
)],
function_name="functionName",
function_scaling_config=lambda.CfnFunction.FunctionScalingConfigProperty(
max_execution_environments=123,
min_execution_environments=123
),
handler="handler",
image_config=lambda.CfnFunction.ImageConfigProperty(
command=["command"],
entry_point=["entryPoint"],
working_directory="workingDirectory"
),
kms_key_arn="kmsKeyArn",
layers=["layers"],
logging_config=lambda.CfnFunction.LoggingConfigProperty(
application_log_level="applicationLogLevel",
log_format="logFormat",
log_group="logGroup",
system_log_level="systemLogLevel"
),
memory_size=123,
package_type="packageType",
publish_to_latest_published=False,
recursive_loop="recursiveLoop",
reserved_concurrent_executions=123,
runtime="runtime",
runtime_management_config=lambda.CfnFunction.RuntimeManagementConfigProperty(
update_runtime_on="updateRuntimeOn",
# the properties below are optional
runtime_version_arn="runtimeVersionArn"
),
snap_start=lambda.CfnFunction.SnapStartProperty(
apply_on="applyOn"
),
tags=[CfnTag(
key="key",
value="value"
)],
tenancy_config=lambda.CfnFunction.TenancyConfigProperty(
tenant_isolation_mode="tenantIsolationMode"
),
timeout=123,
tracing_config=lambda.CfnFunction.TracingConfigProperty(
mode="mode"
),
vpc_config=lambda.CfnFunction.VpcConfigProperty(
ipv6_allowed_for_dual_stack=False,
security_group_ids=["securityGroupIds"],
subnet_ids=["subnetIds"]
)
)
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.lambda.*;
CfnFunction cfnFunction = CfnFunction.Builder.create(this, "MyCfnFunction")
.code(CodeProperty.builder()
.imageUri("imageUri")
.s3Bucket("s3Bucket")
.s3Key("s3Key")
.s3ObjectStorageMode("s3ObjectStorageMode")
.s3ObjectVersion("s3ObjectVersion")
.sourceKmsKeyArn("sourceKmsKeyArn")
.zipFile("zipFile")
.build())
.role("role")
// the properties below are optional
.architectures(List.of("architectures"))
.capacityProviderConfig(CapacityProviderConfigProperty.builder()
.lambdaManagedInstancesCapacityProviderConfig(LambdaManagedInstancesCapacityProviderConfigProperty.builder()
.capacityProviderArn("capacityProviderArn")
// the properties below are optional
.executionEnvironmentMemoryGiBPerVCpu(123)
.perExecutionEnvironmentMaxConcurrency(123)
.build())
.build())
.codeSigningConfigArn("codeSigningConfigArn")
.deadLetterConfig(DeadLetterConfigProperty.builder()
.targetArn("targetArn")
.build())
.description("description")
.durableConfig(DurableConfigProperty.builder()
.executionTimeout(123)
// the properties below are optional
.kmsKeyArn("kmsKeyArn")
.retentionPeriodInDays(123)
.build())
.environment(EnvironmentProperty.builder()
.variables(Map.of(
"variablesKey", "variables"))
.build())
.ephemeralStorage(EphemeralStorageProperty.builder()
.size(123)
.build())
.fileSystemConfigs(List.of(FileSystemConfigProperty.builder()
.arn("arn")
.localMountPath("localMountPath")
// the properties below are optional
.s3FilesConfig(S3FilesConfigProperty.builder()
.directS3Read("directS3Read")
.build())
.build()))
.functionName("functionName")
.functionScalingConfig(FunctionScalingConfigProperty.builder()
.maxExecutionEnvironments(123)
.minExecutionEnvironments(123)
.build())
.handler("handler")
.imageConfig(ImageConfigProperty.builder()
.command(List.of("command"))
.entryPoint(List.of("entryPoint"))
.workingDirectory("workingDirectory")
.build())
.kmsKeyArn("kmsKeyArn")
.layers(List.of("layers"))
.loggingConfig(LoggingConfigProperty.builder()
.applicationLogLevel("applicationLogLevel")
.logFormat("logFormat")
.logGroup("logGroup")
.systemLogLevel("systemLogLevel")
.build())
.memorySize(123)
.packageType("packageType")
.publishToLatestPublished(false)
.recursiveLoop("recursiveLoop")
.reservedConcurrentExecutions(123)
.runtime("runtime")
.runtimeManagementConfig(RuntimeManagementConfigProperty.builder()
.updateRuntimeOn("updateRuntimeOn")
// the properties below are optional
.runtimeVersionArn("runtimeVersionArn")
.build())
.snapStart(SnapStartProperty.builder()
.applyOn("applyOn")
.build())
.tags(List.of(CfnTag.builder()
.key("key")
.value("value")
.build()))
.tenancyConfig(TenancyConfigProperty.builder()
.tenantIsolationMode("tenantIsolationMode")
.build())
.timeout(123)
.tracingConfig(TracingConfigProperty.builder()
.mode("mode")
.build())
.vpcConfig(VpcConfigProperty.builder()
.ipv6AllowedForDualStack(false)
.securityGroupIds(List.of("securityGroupIds"))
.subnetIds(List.of("subnetIds"))
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Lambda;
var cfnFunction = new CfnFunction(this, "MyCfnFunction", new CfnFunctionProps {
Code = new CodeProperty {
ImageUri = "imageUri",
S3Bucket = "s3Bucket",
S3Key = "s3Key",
S3ObjectStorageMode = "s3ObjectStorageMode",
S3ObjectVersion = "s3ObjectVersion",
SourceKmsKeyArn = "sourceKmsKeyArn",
ZipFile = "zipFile"
},
Role = "role",
// the properties below are optional
Architectures = new [] { "architectures" },
CapacityProviderConfig = new CapacityProviderConfigProperty {
LambdaManagedInstancesCapacityProviderConfig = new LambdaManagedInstancesCapacityProviderConfigProperty {
CapacityProviderArn = "capacityProviderArn",
// the properties below are optional
ExecutionEnvironmentMemoryGiBPerVCpu = 123,
PerExecutionEnvironmentMaxConcurrency = 123
}
},
CodeSigningConfigArn = "codeSigningConfigArn",
DeadLetterConfig = new DeadLetterConfigProperty {
TargetArn = "targetArn"
},
Description = "description",
DurableConfig = new DurableConfigProperty {
ExecutionTimeout = 123,
// the properties below are optional
KmsKeyArn = "kmsKeyArn",
RetentionPeriodInDays = 123
},
Environment = new EnvironmentProperty {
Variables = new Dictionary<string, string> {
{ "variablesKey", "variables" }
}
},
EphemeralStorage = new EphemeralStorageProperty {
Size = 123
},
FileSystemConfigs = new [] { new FileSystemConfigProperty {
Arn = "arn",
LocalMountPath = "localMountPath",
// the properties below are optional
S3FilesConfig = new S3FilesConfigProperty {
DirectS3Read = "directS3Read"
}
} },
FunctionName = "functionName",
FunctionScalingConfig = new FunctionScalingConfigProperty {
MaxExecutionEnvironments = 123,
MinExecutionEnvironments = 123
},
Handler = "handler",
ImageConfig = new ImageConfigProperty {
Command = new [] { "command" },
EntryPoint = new [] { "entryPoint" },
WorkingDirectory = "workingDirectory"
},
KmsKeyArn = "kmsKeyArn",
Layers = new [] { "layers" },
LoggingConfig = new LoggingConfigProperty {
ApplicationLogLevel = "applicationLogLevel",
LogFormat = "logFormat",
LogGroup = "logGroup",
SystemLogLevel = "systemLogLevel"
},
MemorySize = 123,
PackageType = "packageType",
PublishToLatestPublished = false,
RecursiveLoop = "recursiveLoop",
ReservedConcurrentExecutions = 123,
Runtime = "runtime",
RuntimeManagementConfig = new RuntimeManagementConfigProperty {
UpdateRuntimeOn = "updateRuntimeOn",
// the properties below are optional
RuntimeVersionArn = "runtimeVersionArn"
},
SnapStart = new SnapStartProperty {
ApplyOn = "applyOn"
},
Tags = new [] { new CfnTag {
Key = "key",
Value = "value"
} },
TenancyConfig = new TenancyConfigProperty {
TenantIsolationMode = "tenantIsolationMode"
},
Timeout = 123,
TracingConfig = new TracingConfigProperty {
Mode = "mode"
},
VpcConfig = new VpcConfigProperty {
Ipv6AllowedForDualStack = false,
SecurityGroupIds = new [] { "securityGroupIds" },
SubnetIds = new [] { "subnetIds" }
}
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
cfnFunction := awscdk.Aws_lambda.NewCfnFunction(this, jsii.String("MyCfnFunction"), &CfnFunctionProps{
Code: &CodeProperty{
ImageUri: jsii.String("imageUri"),
S3Bucket: jsii.String("s3Bucket"),
S3Key: jsii.String("s3Key"),
S3ObjectStorageMode: jsii.String("s3ObjectStorageMode"),
S3ObjectVersion: jsii.String("s3ObjectVersion"),
SourceKmsKeyArn: jsii.String("sourceKmsKeyArn"),
ZipFile: jsii.String("zipFile"),
},
Role: jsii.String("role"),
// the properties below are optional
Architectures: []*string{
jsii.String("architectures"),
},
CapacityProviderConfig: &CapacityProviderConfigProperty{
LambdaManagedInstancesCapacityProviderConfig: &LambdaManagedInstancesCapacityProviderConfigProperty{
CapacityProviderArn: jsii.String("capacityProviderArn"),
// the properties below are optional
ExecutionEnvironmentMemoryGiBPerVCpu: jsii.Number(123),
PerExecutionEnvironmentMaxConcurrency: jsii.Number(123),
},
},
CodeSigningConfigArn: jsii.String("codeSigningConfigArn"),
DeadLetterConfig: &DeadLetterConfigProperty{
TargetArn: jsii.String("targetArn"),
},
Description: jsii.String("description"),
DurableConfig: &DurableConfigProperty{
ExecutionTimeout: jsii.Number(123),
// the properties below are optional
KmsKeyArn: jsii.String("kmsKeyArn"),
RetentionPeriodInDays: jsii.Number(123),
},
Environment: &EnvironmentProperty{
Variables: map[string]*string{
"variablesKey": jsii.String("variables"),
},
},
EphemeralStorage: &EphemeralStorageProperty{
Size: jsii.Number(123),
},
FileSystemConfigs: []interface{}{
&FileSystemConfigProperty{
Arn: jsii.String("arn"),
LocalMountPath: jsii.String("localMountPath"),
// the properties below are optional
S3FilesConfig: &S3FilesConfigProperty{
DirectS3Read: jsii.String("directS3Read"),
},
},
},
FunctionName: jsii.String("functionName"),
FunctionScalingConfig: &FunctionScalingConfigProperty{
MaxExecutionEnvironments: jsii.Number(123),
MinExecutionEnvironments: jsii.Number(123),
},
Handler: jsii.String("handler"),
ImageConfig: &ImageConfigProperty{
Command: []*string{
jsii.String("command"),
},
EntryPoint: []*string{
jsii.String("entryPoint"),
},
WorkingDirectory: jsii.String("workingDirectory"),
},
KmsKeyArn: jsii.String("kmsKeyArn"),
Layers: []interface{}{
jsii.String("layers"),
},
LoggingConfig: &LoggingConfigProperty{
ApplicationLogLevel: jsii.String("applicationLogLevel"),
LogFormat: jsii.String("logFormat"),
LogGroup: jsii.String("logGroup"),
SystemLogLevel: jsii.String("systemLogLevel"),
},
MemorySize: jsii.Number(123),
PackageType: jsii.String("packageType"),
PublishToLatestPublished: jsii.Boolean(false),
RecursiveLoop: jsii.String("recursiveLoop"),
ReservedConcurrentExecutions: jsii.Number(123),
Runtime: jsii.String("runtime"),
RuntimeManagementConfig: &RuntimeManagementConfigProperty{
UpdateRuntimeOn: jsii.String("updateRuntimeOn"),
// the properties below are optional
RuntimeVersionArn: jsii.String("runtimeVersionArn"),
},
SnapStart: &SnapStartProperty{
ApplyOn: jsii.String("applyOn"),
},
Tags: []CfnTag{
&CfnTag{
Key: jsii.String("key"),
Value: jsii.String("value"),
},
},
TenancyConfig: &TenancyConfigProperty{
TenantIsolationMode: jsii.String("tenantIsolationMode"),
},
Timeout: jsii.Number(123),
TracingConfig: &TracingConfigProperty{
Mode: jsii.String("mode"),
},
VpcConfig: &VpcConfigProperty{
Ipv6AllowedForDualStack: jsii.Boolean(false),
SecurityGroupIds: []*string{
jsii.String("securityGroupIds"),
},
SubnetIds: []*string{
jsii.String("subnetIds"),
},
},
})
Initializer
new CfnFunction(scope: Construct, id: string, props: CfnFunctionProps)
CfnFunction(scope: Construct, id: str, props: CfnFunctionProps)
new CfnFunction(Construct scope, String id, CfnFunctionProps props)
new CfnFunction(Construct scope, string id, CfnFunctionProps props)
NewCfnFunction(Scope Construct, Id *string, Props CfnFunctionProps)
Construct Props
architecturesstring[]architecturestyping.List[str]architecturesList<String>Architecturesstring[]Architectures*[]*string#Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64 .
capacityProviderConfigIResolvable | CfnFunction.CapacityProviderConfigPropertycapacity_provider_configtyping.Union[IResolvable, CapacityProviderConfigProperty]capacityProviderConfigIResolvableCapacityProviderConfigIResolvableCapacityProviderConfiginterface{}#codeIResolvable | CfnFunction.CodePropertycodetyping.Union[IResolvable, CodeProperty]codeIResolvableCodeIResolvableCodeinterface{}required#notes
- For .zip deployment packages, you can specify the Amazon S3 location of the .zip file in the
S3Bucket,S3Key, andS3ObjectVersionproperties. - For .zip deployment packages, you can alternatively define the function code inline in the
ZipFileproperty. This method works only for Node.js and Python functions. - For container images, specify the URI of your container image in the Amazon ECR registry in the
ImageUriproperty.
codeSigningConfigArnstring | ICodeSigningConfigRefcode_signing_config_arntyping.Union[str, ICodeSigningConfigRef]codeSigningConfigArnStringCodeSigningConfigArnstringCodeSigningConfigArninterface{}#A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
deadLetterConfigIResolvable | CfnFunction.DeadLetterConfigPropertydead_letter_configtyping.Union[IResolvable, DeadLetterConfigProperty]deadLetterConfigIResolvableDeadLetterConfigIResolvableDeadLetterConfiginterface{}#For more information, see Dead-letter queues .
durableConfigIResolvable | CfnFunction.DurableConfigPropertydurable_configtyping.Union[IResolvable, DurableConfigProperty]durableConfigIResolvableDurableConfigIResolvableDurableConfiginterface{}#environmentIResolvable | CfnFunction.EnvironmentPropertyenvironmenttyping.Union[IResolvable, EnvironmentProperty]environmentIResolvableEnvironmentIResolvableEnvironmentinterface{}#ephemeralStorageIResolvable | CfnFunction.EphemeralStoragePropertyephemeral_storagetyping.Union[IResolvable, EphemeralStorageProperty]ephemeralStorageIResolvableEphemeralStorageIResolvableEphemeralStorageinterface{}#The default value is 512, but it can be any whole number between 512 and 10,240 MB.
fileSystemConfigsIResolvable | IResolvable | CfnFunction.FileSystemConfigProperty[]file_system_configstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, FileSystemConfigProperty]]]fileSystemConfigsIResolvableFileSystemConfigsIResolvableFileSystemConfigsinterface{}#notes
To connect a function to a file system, a mount target must be available in every Availability Zone that your function connects to. If your template contains an AWS::EFS::MountTarget resource, you must also specify a DependsOn attribute to ensure that the mount target is created or updated before the function.
For more information about using the DependsOn attribute, see DependsOn Attribute .
notes
If you don't specify a name, CloudFormation generates one.
If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name.
functionScalingConfigIResolvable | CfnFunction.FunctionScalingConfigPropertyfunction_scaling_configtyping.Union[IResolvable, FunctionScalingConfigProperty]functionScalingConfigIResolvableFunctionScalingConfigIResolvableFunctionScalingConfiginterface{}#notes
Handler is required if the deployment package is a .zip file archive. The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see Lambda programming model .
imageConfigIResolvable | CfnFunction.ImageConfigPropertyimage_configtyping.Union[IResolvable, ImageConfigProperty]imageConfigIResolvableImageConfigIResolvableImageConfiginterface{}#For more information, see Container image settings .
kmsKeyArnstring | IKeyRefkms_key_arntyping.Union[str, IKeyRef]kmsKeyArnStringKmsKeyArnstringKmsKeyArninterface{}#notes
- The function's environment variables .
- The function's Lambda SnapStart snapshots.
- When used with
SourceKMSKeyArn, the unzipped version of the .zip deployment package that's used for function invocations. For more information, see Specifying a customer managed key for Lambda . - The optimized version of the container image that's used for function invocations. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). For more information, see Function lifecycle .
If you don't provide a customer managed key, Lambda uses an AWS owned key or an AWS managed key .
layersstring | ILayerVersionRef[]layerstyping.List[typing.Union[str, ILayerVersionRef]]layersList<String>Layersstring[]Layers*[]interface{}#loggingConfigIResolvable | CfnFunction.LoggingConfigPropertylogging_configtyping.Union[IResolvable, LoggingConfigProperty]loggingConfigIResolvableLoggingConfigIResolvableLoggingConfiginterface{}#Set to Image for container image and set Zip for .zip file archive.
publishToLatestPublishedboolean | IResolvablepublish_to_latest_publishedtyping.Union[bool, IResolvable]publishToLatestPublishedBooleanPublishToLatestPublishedboolPublishToLatestPublishedinterface{}#notes
When this value is set to Allow and Lambda detects your function being invoked as part of a recursive loop, it doesn't take any action.
When this value is set to Terminate and Lambda detects your function being invoked as part of a recursive loop, it stops your function being invoked and notifies you.
reservedConcurrentExecutionsnumberreserved_concurrent_executionsint | floatreservedConcurrentExecutionsNumberReservedConcurrentExecutionsdoubleReservedConcurrentExecutions*float64#notes
The following list includes deprecated runtimes. Lambda blocks creating new functions and updating existing functions shortly after each runtime is deprecated. For more information, see Runtime use after deprecation .
For a list of all currently supported runtimes, see Supported runtimes .
runtimeManagementConfigIResolvable | CfnFunction.RuntimeManagementConfigPropertyruntime_management_configtyping.Union[IResolvable, RuntimeManagementConfigProperty]runtimeManagementConfigIResolvableRuntimeManagementConfigIResolvableRuntimeManagementConfiginterface{}#For more information, see Runtime updates .
snapStartIResolvable | CfnFunction.SnapStartPropertysnap_starttyping.Union[IResolvable, SnapStartProperty]snapStartIResolvableSnapStartIResolvableSnapStartinterface{}#notes
You must have the
lambda:TagResource,lambda:UntagResource, andlambda:ListTagspermissions for your IAM principal to manage the CloudFormation stack. If you don't have these permissions, there might be unexpected behavior with stack-level tags propagating to the resource during resource creation and update.
tenancyConfigIResolvable | CfnFunction.TenancyConfigPropertytenancy_configtyping.Union[IResolvable, TenancyConfigProperty]tenancyConfigIResolvableTenancyConfigIResolvableTenancyConfiginterface{}#Determines whether the Lambda function runs on a shared or dedicated infrastructure per unique tenant.
The default is 3 seconds. The maximum allowed value is 900 seconds. For more information, see Lambda execution environment .
tracingConfigIResolvable | CfnFunction.TracingConfigPropertytracing_configtyping.Union[IResolvable, TracingConfigProperty]tracingConfigIResolvableTracingConfigIResolvableTracingConfiginterface{}#vpcConfigIResolvable | CfnFunction.VpcConfigPropertyvpc_configtyping.Union[IResolvable, VpcConfigProperty]vpcConfigIResolvableVpcConfigIResolvableVpcConfiginterface{}#notes
When you connect a function to a VPC, it can access resources and the internet only through that VPC. For more information, see Configuring a Lambda function to access resources in a VPC .
Properties
architecturesstring[]architecturestyping.List[str]architecturesList<String>Architecturesstring[]Architectures*[]*string#attrSnapStartResponseIResolvableattr_snap_start_responseIResolvableattrSnapStartResponseIResolvableAttrSnapStartResponseIResolvableAttrSnapStartResponseIResolvablerequired#attrSnapStartResponseApplyOnstringattr_snap_start_response_apply_onstrattrSnapStartResponseApplyOnStringAttrSnapStartResponseApplyOnstringAttrSnapStartResponseApplyOn*stringrequired#attrSnapStartResponseOptimizationStatusstringattr_snap_start_response_optimization_statusstrattrSnapStartResponseOptimizationStatusStringAttrSnapStartResponseOptimizationStatusstringAttrSnapStartResponseOptimizationStatus*stringrequired#capacityProviderConfigIResolvable | CfnFunction.CapacityProviderConfigPropertycapacity_provider_configtyping.Union[IResolvable, CapacityProviderConfigProperty]capacityProviderConfigIResolvableCapacityProviderConfigIResolvableCapacityProviderConfiginterface{}#CFN_RESOURCE_TYPE_NAMEstringcfn_resource_type_namestrCFN_RESOURCE_TYPE_NAMEStringCFN_RESOURCE_TYPE_NAMEstringCFN_RESOURCE_TYPE_NAME*stringrequiredstatic#cfnOptionsICfnResourceOptionscfn_optionsICfnResourceOptionscfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsCfnOptionsICfnResourceOptionsrequired#cfnResourceTypestringcfn_resource_typestrcfnResourceTypeStringCfnResourceTypestringCfnResourceType*stringrequired#codeIResolvable | CfnFunction.CodePropertycodetyping.Union[IResolvable, CodeProperty]codeIResolvableCodeIResolvableCodeinterface{}required#You can define your function code in multiple ways:.
codeSigningConfigArnstringcode_signing_config_arnstrcodeSigningConfigArnStringCodeSigningConfigArnstringCodeSigningConfigArn*string#creationStackstring[]creation_stacktyping.List[str]creationStackList<String>CreationStackstring[]CreationStack*[]*stringrequired#deadLetterConfigIResolvable | CfnFunction.DeadLetterConfigPropertydead_letter_configtyping.Union[IResolvable, DeadLetterConfigProperty]deadLetterConfigIResolvableDeadLetterConfigIResolvableDeadLetterConfiginterface{}#durableConfigIResolvable | CfnFunction.DurableConfigPropertydurable_configtyping.Union[IResolvable, DurableConfigProperty]durableConfigIResolvableDurableConfigIResolvableDurableConfiginterface{}#environmentIResolvable | CfnFunction.EnvironmentPropertyenvironmenttyping.Union[IResolvable, EnvironmentProperty]environmentIResolvableEnvironmentIResolvableEnvironmentinterface{}#ephemeralStorageIResolvable | CfnFunction.EphemeralStoragePropertyephemeral_storagetyping.Union[IResolvable, EphemeralStorageProperty]ephemeralStorageIResolvableEphemeralStorageIResolvableEphemeralStorageinterface{}#fileSystemConfigsIResolvable | IResolvable | CfnFunction.FileSystemConfigProperty[]file_system_configstyping.Union[IResolvable, typing.List[typing.Union[IResolvable, FileSystemConfigProperty]]]fileSystemConfigsIResolvableFileSystemConfigsIResolvableFileSystemConfigsinterface{}#functionRefFunctionReferencefunction_refFunctionReferencefunctionRefFunctionReferenceFunctionRefFunctionReferenceFunctionRefFunctionReferencerequired#functionScalingConfigIResolvable | CfnFunction.FunctionScalingConfigPropertyfunction_scaling_configtyping.Union[IResolvable, FunctionScalingConfigProperty]functionScalingConfigIResolvableFunctionScalingConfigIResolvableFunctionScalingConfiginterface{}#imageConfigIResolvable | CfnFunction.ImageConfigPropertyimage_configtyping.Union[IResolvable, ImageConfigProperty]imageConfigIResolvableImageConfigIResolvableImageConfiginterface{}#loggingConfigIResolvable | CfnFunction.LoggingConfigPropertylogging_configtyping.Union[IResolvable, LoggingConfigProperty]loggingConfigIResolvableLoggingConfigIResolvableLoggingConfiginterface{}#The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use overrideLogicalId(newLogicalId).
publishToLatestPublishedboolean | IResolvablepublish_to_latest_publishedtyping.Union[bool, IResolvable]publishToLatestPublishedBooleanPublishToLatestPublishedboolPublishToLatestPublishedinterface{}#If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through Lazy.any({ produce: resource.ref }).
reservedConcurrentExecutionsnumberreserved_concurrent_executionsint | floatreservedConcurrentExecutionsNumberReservedConcurrentExecutionsdoubleReservedConcurrentExecutions*float64#runtimeManagementConfigIResolvable | CfnFunction.RuntimeManagementConfigPropertyruntime_management_configtyping.Union[IResolvable, RuntimeManagementConfigProperty]runtimeManagementConfigIResolvableRuntimeManagementConfigIResolvableRuntimeManagementConfiginterface{}#snapStartIResolvable | CfnFunction.SnapStartPropertysnap_starttyping.Union[IResolvable, SnapStartProperty]snapStartIResolvableSnapStartIResolvableSnapStartinterface{}#CfnElements must be defined within a stack scope (directly or indirectly).
tenancyConfigIResolvable | CfnFunction.TenancyConfigPropertytenancy_configtyping.Union[IResolvable, TenancyConfigProperty]tenancyConfigIResolvableTenancyConfigIResolvableTenancyConfiginterface{}#tracingConfigIResolvable | CfnFunction.TracingConfigPropertytracing_configtyping.Union[IResolvable, TracingConfigProperty]tracingConfigIResolvableTracingConfigIResolvableTracingConfiginterface{}#vpcConfigIResolvable | CfnFunction.VpcConfigPropertyvpc_configtyping.Union[IResolvable, VpcConfigProperty]vpcConfigIResolvableVpcConfigIResolvableVpcConfiginterface{}#Methods
addDeletionOverride(path: string): voiddef add_deletion_override(self, path: str) -> Nonepublic void addDeletionOverride(String path)public void AddDeletionOverride(string path)func AddDeletionOverride(Path *string)#1 parameter
Parameters
pathpathpathpathPath— The path of the value to delete.
addDependency(target: CfnResource): voiddef add_dependency(self, target: CfnResource) -> Nonepublic void addDependency(CfnResource target)public void AddDependency(CfnResource target)func AddDependency(Target CfnResource)deprecated#This method has been renamed to addResourceDependency to more clearly set it apart from construct.node.addDependency. See the documentation of that function for more details.
addDependsOn(target: CfnResource): voiddef add_depends_on(self, target: CfnResource) -> Nonepublic void addDependsOn(CfnResource target)public void AddDependsOn(CfnResource target)func AddDependsOn(Target CfnResource)deprecated#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method has been renamed to addResourceDependency, which makes it more clear that this method operates at a different level from the construct-level construct.node.addDependency() mechanism.
addMetadata(key: string, value: any): voiddef add_metadata(self, key: str, value: Any) -> Nonepublic void addMetadata(String key, Object value)public void AddMetadata(string key, object value)func AddMetadata(Key *string, Value interface{})#addOverride(path: string, value: any): voiddef add_override(self, path: str, value: Any) -> Nonepublic void addOverride(String path, Object value)public void AddOverride(string path, object value)func AddOverride(Path *string, Value interface{})#notes · 2 parameters
To add a property override, either use addPropertyOverride or prefix path with "Properties." (i.e. Properties.TopicName).
If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal . in the property name, prefix with a \. In most programming languages you will need to write this as "\\." because the \ itself will need to be escaped.
For example,
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes', ['myattribute']);
cfnResource.addOverride('Properties.GlobalSecondaryIndexes.1.ProjectionType', 'INCLUDE');
would add the overrides
"Properties": {
"GlobalSecondaryIndexes": [
{
"Projection": {
"NonKeyAttributes": [ "myattribute" ]
...
}
...
},
{
"ProjectionType": "INCLUDE"
...
},
]
...
}
The value argument to addOverride will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.
Parameters
pathpathpathpathPath— - The path of the property, you can use dot notation to override values in complex types.valuevaluevaluevalueValue— - The value.
addPropertyDeletionOverride(propertyPath: string): voiddef add_property_deletion_override(self, property_path: str) -> Nonepublic void addPropertyDeletionOverride(String propertyPath)public void AddPropertyDeletionOverride(string propertyPath)func AddPropertyDeletionOverride(PropertyPath *string)#1 parameter
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path to the property.
addPropertyOverride(propertyPath: string, value: any): voiddef add_property_override(self, property_path: str, value: Any) -> Nonepublic void addPropertyOverride(String propertyPath, Object value)public void AddPropertyOverride(string propertyPath, object value)func AddPropertyOverride(PropertyPath *string, Value interface{})#Syntactic sugar for addOverride("Properties.<...>", value).
2 parameters
Parameters
propertyPathproperty_pathpropertyPathpropertyPathPropertyPath— The path of the property.valuevaluevaluevalueValue— The value.
addResourceDependency(target: CfnResource, reason?: string): voiddef add_resource_dependency(self, target: CfnResource, reason: typing.Optional[str] = None) -> Nonepublic void addResourceDependency(CfnResource target, String reason)public void AddResourceDependency(CfnResource target, string? reason = null)func AddResourceDependency(Target CfnResource, Reason *string)#notes
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
This method only adds dependencies between L1 resources. If you are looking for a generic construct-to-construct dependency mechanism that works for all constructs including L2s, use construct.node.addDependency instead.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#When set, any cross-stack reference to this resource will use the specified strength instead of the global default from the consuming stack's context.
1 parameter
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy?: RemovalPolicy, options?: RemovalPolicyOptions): voiddef apply_removal_policy(self, policy: typing.Optional[RemovalPolicy] = None, options: typing.Optional[RemovalPolicyOptions] = None) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy, RemovalPolicyOptions options)public void ApplyRemovalPolicy(RemovalPolicy? policy = null, RemovalPolicyOptions? options = null)func ApplyRemovalPolicy(Policy RemovalPolicy, Options RemovalPolicyOptions)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN). In some cases, a snapshot can be taken of the resource prior to deletion (RemovalPolicy.SNAPSHOT). A list of resources that support this policy can be found in the following link:
arnForFunction(resource: IFunctionRef): string@staticmethod def arn_for_function(resource: IFunctionRef) -> strpublic static String arnForFunction(IFunctionRef resource)public static string ArnForFunction(IFunctionRef resource)func ArnForFunction(Resource IFunctionRef) *stringstatic#cfnPropertyName(cdkPropertyName: string): stringdef cfn_property_name(self, cdk_property_name: str) -> strpublic String cfnPropertyName(String cdkPropertyName)public string CfnPropertyName(string cdkPropertyName)func CfnPropertyName(CdkPropertyName *string) *string#fromFunctionArn(scope: Construct, id: string, arn: string): IFunctionRef@staticmethod def from_function_arn(scope: Construct, id: str, arn: str) -> IFunctionRefpublic static IFunctionRef fromFunctionArn(Construct scope, String id, String arn)public static IFunctionRef FromFunctionArn(Construct scope, string id, string arn)func FromFunctionArn(Scope Construct, Id *string, Arn *string) IFunctionRefstatic#fromFunctionName(scope: Construct, id: string, functionName: string): IFunctionRef@staticmethod def from_function_name(scope: Construct, id: str, function_name: str) -> IFunctionRefpublic static IFunctionRef fromFunctionName(Construct scope, String id, String functionName)public static IFunctionRef FromFunctionName(Construct scope, string id, string functionName)func FromFunctionName(Scope Construct, Id *string, FunctionName *string) IFunctionRefstatic#getAtt(attributeName: string, typeHint?: ResolutionTypeHint): Referencedef get_att(self, attribute_name: str, type_hint: typing.Optional[ResolutionTypeHint] = None) -> Referencepublic Reference getAtt(String attributeName, ResolutionTypeHint typeHint)public Reference GetAtt(string attributeName, ResolutionTypeHint? typeHint = null)func GetAtt(AttributeName *string, TypeHint ResolutionTypeHint) Reference#Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.
1 parameter
Parameters
attributeNameattribute_nameattributeNameattributeNameAttributeName— The name of the attribute.
getMetadata(key: string): anydef get_metadata(self, key: str) -> Anypublic Object getMetadata(String key)public object GetMetadata(string key)func GetMetadata(Key *string) interface{}#inspect(inspector: TreeInspector): voiddef inspect(self, inspector: TreeInspector) -> Nonepublic void inspect(TreeInspector inspector)public void Inspect(TreeInspector inspector)func Inspect(Inspector TreeInspector)#1 parameter
Parameters
inspectorinspectorinspectorinspectorInspector— tree inspector to collect and process attributes.
isCfnElement(x: any): boolean@staticmethod def is_cfn_element(x: Any) -> boolpublic static Boolean isCfnElement(Object x)public static bool IsCfnElement(object x)func IsCfnElement(X interface{}) *boolstatic#Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.
returns
Returns: The construct as a stack element or undefined if it is not a stack element.
isCfnFunction(x: any): boolean@staticmethod def is_cfn_function(x: Any) -> boolpublic static Boolean isCfnFunction(Object x)public static bool IsCfnFunction(object x)func IsCfnFunction(X interface{}) *boolstatic#isCfnResource(x: any): boolean@staticmethod def is_cfn_resource(x: Any) -> boolpublic static Boolean isCfnResource(Object x)public static bool IsCfnResource(object x)func IsCfnResource(X interface{}) *boolstatic#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
obtainDependencies(): Stack | CfnResource[]def obtain_dependencies(self, ) -> typing.List[typing.Union[Stack, CfnResource]]public List<Stack> obtainDependencies()public Stack[] ObtainDependencies()func ObtainDependencies() *[]interface{}#For resources depended on directly, returns the CfnResource object. For dependencies on other stacks, returns the Stack object. The order of the array is not guaranteed.
overrideLogicalId(newLogicalId: string): voiddef override_logical_id(self, new_logical_id: str) -> Nonepublic void overrideLogicalId(String newLogicalId)public void OverrideLogicalId(string newLogicalId)func OverrideLogicalId(NewLogicalId *string)#1 parameter
Parameters
newLogicalIdnew_logical_idnewLogicalIdnewLogicalIdNewLogicalId— The new logical ID to use for this stack element.
removeDependency(target: CfnResource): voiddef remove_dependency(self, target: CfnResource) -> Nonepublic void removeDependency(CfnResource target)public void RemoveDependency(CfnResource target)func RemoveDependency(Target CfnResource)deprecated#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
removeResourceDependency(target: CfnResource): voiddef remove_resource_dependency(self, target: CfnResource) -> Nonepublic void removeResourceDependency(CfnResource target)public void RemoveResourceDependency(CfnResource target)func RemoveResourceDependency(Target CfnResource)#This can be used for resources across stacks (including nested stacks) and the dependency will automatically be removed from the relevant scope.
replaceDependency(target: CfnResource, newTarget: CfnResource): voiddef replace_dependency(self, target: CfnResource, new_target: CfnResource) -> Nonepublic void replaceDependency(CfnResource target, CfnResource newTarget)public void ReplaceDependency(CfnResource target, CfnResource newTarget)func ReplaceDependency(Target CfnResource, NewTarget CfnResource)#2 parameters
Parameters
targettargettargettargetTarget— The dependency to replace.newTargetnew_targetnewTargetnewTargetNewTarget— The new dependency to add.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#returns
Returns: a string representation of this resource
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.