AWS::Lambda::Function¶
The AWS::Lambda::Function resource creates a Lambda function.
Generated by cfn-typegen --out cfn_types AWS::Lambda::Function into cfn_types/lambda_.py:
# Generated by cfn-typegen from the CloudFormation registry schemas. Do not edit.
# fmt: off
# ruff: noqa
"""AWS::Lambda resources."""
from collections.abc import Mapping, Sequence
from typing import Any, Literal, NotRequired, Unpack
from typing_extensions import TypedDict
from cfn_typed.base import DeletionPolicy, DependsOn, ResourceAttrs, Tag, UpdateReplacePolicy, build
from cfn_typed.intrinsics import Expr
_c0="^(arn:(aws[a-zA-Z-]*)?:[a-z0-9-.]+:.*)|()$"
_c1=["PublishedVersions","None"]
CONSTRAINTS:dict[str,Any]={
'AWS::Lambda::Function':{'FunctionScalingConfig':{'P':{'MinExecutionEnvironments':{'m':0,'M':15000},'MaxExecutionEnvironments':{'m':0,'M':15000}}},'Description':{'L':256},'TracingConfig':{'P':{'Mode':{'e':["Active","PassThrough"]}}},'VpcConfig':{'P':{'SecurityGroupIds':{'I':5},'SubnetIds':{'I':16}}},'RuntimeManagementConfig':{'P':{'UpdateRuntimeOn':{'e':["Auto","FunctionUpdate","Manual"]}}},'DurableConfig':{'P':{'KMSKeyArn':{'p':_c0},'ExecutionTimeout':{'m':1,'M':31622400},'RetentionPeriodInDays':{'m':1,'M':90}}},'ReservedConcurrentExecutions':{'m':0},'SnapStart':{'P':{'ApplyOn':{'e':_c1}}},'FileSystemConfigs':{'I':1,'T':{'P':{'S3FilesConfig':{'P':{'DirectS3Read':{'e':["ENABLED","DISABLED","AUTO"]}}},'Arn':{'p':"^arn:aws[a-zA-Z-]*:elasticfilesystem:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:access-point/fsap-[a-f0-9]{17}$|^arn:aws[-a-z]*:s3files:[0-9a-z-:]+:file-system/fs-[0-9a-f]{17,40}/access-point/fsap-[0-9a-f]{17,40}$",'L':200},'LocalMountPath':{'p':"^/mnt/[a-zA-Z0-9-_.]+$",'L':160}}}},'FunctionName':{'l':1},'KmsKeyArn':{'p':_c0},'PackageType':{'e':["Image","Zip"]},'CodeSigningConfigArn':{'p':"arn:(aws[a-zA-Z-]*)?:lambda:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:code-signing-config:csc-[a-z0-9]{17}"},'TenancyConfig':{'P':{'TenantIsolationMode':{'e':["PER_TENANT"]}}},'Tags':{'T':{'P':{'Value':{'l':0,'L':256},'Key':{'l':1,'L':128}}}},'ImageConfig':{'P':{'Command':{'I':1500},'EntryPoint':{'I':1500}}},'DeadLetterConfig':{'P':{'TargetArn':{'p':_c0}}},'Timeout':{'m':1},'CapacityProviderConfig':{'P':{'LambdaManagedInstancesCapacityProviderConfig':{'P':{'ExecutionEnvironmentMemoryGiBPerVCpu':{'m':2,'M':8},'CapacityProviderArn':{'p':"^arn:aws[a-zA-Z-]*:lambda:(eusc-)?[a-z]{2}((-gov)|(-iso([a-z]?)))?-[a-z]+-\\d{1}:\\d{12}:capacity-provider:[a-zA-Z0-9-_]+$",'l':1,'L':140},'PerExecutionEnvironmentMaxConcurrency':{'m':1,'M':1600}}}}},'Handler':{'p':"^[^\\s]+$",'L':128},'SnapStartResponse':{'P':{'OptimizationStatus':{'e':["On","Off"]},'ApplyOn':{'e':_c1}}},'Code':{'P':{'SourceKMSKeyArn':{'p':_c0},'S3ObjectVersion':{'l':1,'L':1024},'S3Bucket':{'p':"^[0-9A-Za-z\\.\\-_]*(?<!\\.)$",'l':3,'L':63},'S3Key':{'l':1,'L':1024},'S3ObjectStorageMode':{'e':["COPY","REFERENCE"]}}},'Role':{'p':"^arn:(aws[a-zA-Z-]*)?:iam::\\d{12}:role/?[a-zA-Z_0-9+=,.@\\-_/]+$"},'LoggingConfig':{'P':{'LogFormat':{'e':["Text","JSON"]},'ApplicationLogLevel':{'e':["TRACE","DEBUG","INFO","WARN","ERROR","FATAL"]},'LogGroup':{'p':"[\\.\\-_/#A-Za-z0-9]+",'l':1,'L':512},'SystemLogLevel':{'e':["DEBUG","INFO","WARN"]}}},'RecursiveLoop':{'e':["Allow","Terminate"]},'EphemeralStorage':{'P':{'Size':{'m':512,'M':32768}}},'Architectures':{'i':1,'I':1,'T':{'e':["x86_64","arm64"]}}},
}
ATTRIBUTES:dict[str,Any]={"AWS::Lambda::Function":["Arn","FunctionName","SnapStartResponse","SnapStartResponse.ApplyOn","SnapStartResponse.OptimizationStatus"]}
RULES:dict[str,Any]={}
Nested types (20)
These are defined above the properties in the generated module.
class FunctionFunctionScalingConfig(TypedDict, closed=True):
'Configuration that defines the scaling behavior for a Lambda Managed Instances function, including the minimum and maximum number of execution environments t...'
MinExecutionEnvironments: NotRequired[Expr[int]]
'The minimum number of execution environments to maintain for the function.'
MaxExecutionEnvironments: NotRequired[Expr[int]]
'The maximum number of execution environments that can be provisioned for the function.'
class FunctionTracingConfig(TypedDict, closed=True):
"The function's [](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html) tracing configuration."
Mode: NotRequired[Expr[str]]
'The tracing mode.'
class FunctionVpcConfig(TypedDict, closed=True):
'The VPC security groups and subnets that are attached to a Lambda function.'
Ipv6AllowedForDualStack: NotRequired[Expr[bool]]
'Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.'
SecurityGroupIds: NotRequired[Expr[list[Expr[str]]]]
'A list of VPC security group IDs.'
SubnetIds: NotRequired[Expr[list[Expr[str]]]]
'A list of VPC subnet IDs.'
class FunctionRuntimeManagementConfig(TypedDict, closed=True):
"Sets the runtime management configuration for a function's version."
UpdateRuntimeOn: Expr[str]
'Specify the runtime update mode.'
RuntimeVersionArn: NotRequired[Expr[str]]
'The ARN of the runtime version you want the function to use.'
class FunctionDurableConfig(TypedDict, closed=True):
'Configuration settings for [durable functions](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html), including execution timeout, retention p...'
KMSKeyArn: NotRequired[Expr[str]]
"The ARN of the KMSlong (KMS) customer managed key that is used to encrypt your durable execution's payload data, including input, output, and error payloads."
ExecutionTimeout: Expr[int]
'The maximum time (in seconds) that a durable execution can run before timing out.'
RetentionPeriodInDays: NotRequired[Expr[int]]
'The number of days to retain execution history after a durable execution completes.'
class FunctionSnapStart(TypedDict, closed=True):
"The function's [SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting."
ApplyOn: Expr[str]
'Set ``ApplyOn`` to ``PublishedVersions`` to create a snapshot of the initialized execution environment when you publish a function version.'
class FunctionS3FilesConfig(TypedDict, closed=True):
'Setting controls how your function accesses data from an Amazon S3 file system.'
DirectS3Read: NotRequired[Expr[str]]
'Specifies if a function reads from the file system for the lowest latency, or through Amazon S3 Files feature "direct Amazon S3 bucket reads" for the highest...'
class FunctionFileSystemConfig(TypedDict, closed=True):
'Details about the connection between a Lambda function and an [Amazon EFS file system](https://docs.aws.amazon.com/lambda/latest/dg/configuration-filesystem....'
S3FilesConfig: NotRequired[Expr[FunctionS3FilesConfig]]
'The configuration for how your function accesses data on an Amazon S3 file system.'
Arn: Expr[str]
'The Amazon Resource Name (ARN) of the Amazon EFS or Amazon S3 Files access point that provides access to the file system.'
LocalMountPath: Expr[str]
'The path where the function can access the file system, starting with ``/mnt/``.'
class FunctionTenancyConfig(TypedDict, closed=True):
'Specifies the tenant isolation mode configuration for a Lambda function.'
TenantIsolationMode: Expr[str]
'Tenant isolation mode allows for invocation to be sent to a corresponding execution environment dedicated to a specific tenant ID.'
class FunctionImageConfig(TypedDict, closed=True):
'Configuration values that override the container image Dockerfile settings.'
WorkingDirectory: NotRequired[Expr[str]]
'Specifies the working directory.'
Command: NotRequired[Expr[list[Expr[str]]]]
'Specifies parameters that you want to pass in with ENTRYPOINT.'
EntryPoint: NotRequired[Expr[list[Expr[str]]]]
'Specifies the entry point to their application, which is typically the location of the runtime executable.'
class FunctionDeadLetterConfig(TypedDict, closed=True):
'The [dead-letter queue](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async-retain-records.html#invocation-dlq) for failed asynchronous invocations.'
TargetArn: NotRequired[Expr[str]]
'The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.'
class FunctionLambdaManagedInstancesCapacityProviderConfig(TypedDict, closed=True):
'Configuration for Lambda-managed instances used by the capacity provider.'
ExecutionEnvironmentMemoryGiBPerVCpu: NotRequired[Expr[float]]
'The amount of memory in GiB allocated per vCPU for execution environments.'
CapacityProviderArn: Expr[str]
'The Amazon Resource Name (ARN) of the capacity provider.'
PerExecutionEnvironmentMaxConcurrency: NotRequired[Expr[int]]
'The maximum number of concurrent executions that can run on each execution environment.'
class FunctionCapacityProviderConfig(TypedDict, closed=True):
'Configuration for the capacity provider that manages compute resources for Lambda functions.'
LambdaManagedInstancesCapacityProviderConfig: Expr[FunctionLambdaManagedInstancesCapacityProviderConfig]
'Configuration for Lambda-managed instances used by the capacity provider.'
class FunctionCode(TypedDict, closed=True):
'The [deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html) for a Lambda function.'
SourceKMSKeyArn: NotRequired[Expr[str]]
"The ARN of the KMSlong (KMS) customer managed key that's used to encrypt your function's .zip deployment package."
S3ObjectVersion: NotRequired[Expr[str]]
'For versioned objects, the version of the deployment package object to use.'
S3Bucket: NotRequired[Expr[str]]
'An Amazon S3 bucket in the same AWS-Region as your function.'
ZipFile: NotRequired[Expr[str]]
'(Node.js and Python) The source code of your Lambda function.'
S3Key: NotRequired[Expr[str]]
'The Amazon S3 key of the deployment package.'
S3ObjectStorageMode: NotRequired[Expr[str]]
'Specifies the storage mode for the deployment package.'
ImageUri: NotRequired[Expr[str]]
'URI of a [container image](https://docs.aws.amazon.com/lambda/latest/dg/lambda-images.html) in the Amazon ECR registry.'
class FunctionLoggingConfig(TypedDict, closed=True):
"The function's Amazon CloudWatch Logs configuration settings."
LogFormat: NotRequired[Expr[str]]
"The format in which Lambda sends your function's application and system logs to CloudWatch."
ApplicationLogLevel: NotRequired[Expr[str]]
'Set this property to filter the application logs for your function that Lambda sends to CloudWatch.'
LogGroup: NotRequired[Expr[str]]
'The name of the Amazon CloudWatch log group the function sends logs to.'
SystemLogLevel: NotRequired[Expr[str]]
'Set this property to filter the system logs for your function that Lambda sends to CloudWatch.'
class FunctionEnvironment(TypedDict, closed=True):
"A function's environment variable settings."
Variables: NotRequired[Expr[Mapping[str, Expr[str]]]]
'Environment variable key-value pairs.'
class FunctionEphemeralStorage(TypedDict, closed=True):
"The size of the function's ``/tmp`` directory in MB."
Size: Expr[int]
"The size of the function's ``/tmp`` directory."
class FunctionProps(TypedDict, closed=True):
'The ``AWS::Lambda::Function`` resource creates a Lambda function.'
FunctionScalingConfig: NotRequired[Expr[FunctionFunctionScalingConfig]]
'Configuration that defines the scaling behavior for a Lambda Managed Instances function, including the minimum and maximum number of execution environments t...'
Description: NotRequired[Expr[str]]
'A description of the function.'
TracingConfig: NotRequired[Expr[FunctionTracingConfig]]
'Set ``Mode`` to ``Active`` to sample and trace a subset of incoming requests with [X-Ray](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html).'
VpcConfig: NotRequired[Expr[FunctionVpcConfig]]
'For network connectivity to AWS resources in a VPC, specify a list of security groups and subnets in the VPC.'
RuntimeManagementConfig: NotRequired[Expr[FunctionRuntimeManagementConfig]]
"Sets the runtime management configuration for a function's version."
DurableConfig: NotRequired[Expr[FunctionDurableConfig]]
'Configuration settings for [durable functions](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html), including execution timeout, retention p...'
ReservedConcurrentExecutions: NotRequired[Expr[int]]
'The number of simultaneous executions to reserve for the function.'
SnapStart: NotRequired[Expr[FunctionSnapStart]]
"The function's [SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting."
FileSystemConfigs: NotRequired[Expr[Sequence[Expr[FunctionFileSystemConfig]]]]
'Connection settings for an Amazon EFS or Amazon S3 Files file system.'
FunctionName: NotRequired[Expr[str]]
'The name of the Lambda function, up to 64 characters in length.'
Runtime: NotRequired[Expr[str]]
"The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html)."
KmsKeyArn: NotRequired[Expr[str]]
"The ARN of the KMSlong (KMS) customer managed key that's used to encrypt the following resources: + The function's [environment variables](https://docs.aws.a..."
PublishToLatestPublished: NotRequired[Expr[bool]]
PackageType: NotRequired[Expr[str]]
'The type of deployment package.'
CodeSigningConfigArn: NotRequired[Expr[str]]
'To enable code signing for this function, specify the ARN of a code-signing configuration.'
Layers: NotRequired[Expr[list[Expr[str]]]]
"A list of [function layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) to add to the function's execution environment."
TenancyConfig: NotRequired[Expr[FunctionTenancyConfig]]
"The function's tenant isolation configuration settings."
Tags: NotRequired[Expr[Sequence[Expr[Tag]]]]
'A list of [tags](https://docs.aws.amazon.com/lambda/latest/dg/tagging.html) to apply to the function.'
ImageConfig: NotRequired[Expr[FunctionImageConfig]]
'Configuration values that override the container image Dockerfile settings.'
MemorySize: NotRequired[Expr[int]]
'The amount of [memory available to the function](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console...'
DeadLetterConfig: NotRequired[Expr[FunctionDeadLetterConfig]]
'A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.'
Timeout: NotRequired[Expr[int]]
'The amount of time (in seconds) that Lambda allows a function to run before stopping it.'
CapacityProviderConfig: NotRequired[Expr[FunctionCapacityProviderConfig]]
'Configuration for the capacity provider that manages compute resources for Lambda functions.'
Handler: NotRequired[Expr[str]]
'The name of the method within your code that Lambda calls to run your function.'
Code: Expr[FunctionCode]
'The code for the function.'
Role: Expr[str]
"The Amazon Resource Name (ARN) of the function's execution role."
LoggingConfig: NotRequired[Expr[FunctionLoggingConfig]]
"The function's Amazon CloudWatch Logs configuration settings."
RecursiveLoop: NotRequired[Expr[str]]
"The status of your function's recursive loop detection configuration."
Environment: NotRequired[Expr[FunctionEnvironment]]
'Environment variables that are accessible from function code during execution.'
EphemeralStorage: NotRequired[Expr[FunctionEphemeralStorage]]
"The size of the function's ``/tmp`` directory in MB."
Architectures: NotRequired[Expr[list[Expr[str]]]]
'The instruction set architecture that the function supports.'
class Function(ResourceAttrs):
'The ``AWS::Lambda::Function`` resource creates a Lambda function.'
Type: Literal['AWS::Lambda::Function']
Properties: FunctionProps
def function(
*,
depends_on: DependsOn | None = None,
deletion_policy: DeletionPolicy | None = None,
update_replace_policy: UpdateReplacePolicy | None = None,
condition: str | None = None,
metadata: dict[str, Any] | None = None,
**props: Unpack[FunctionProps],
) -> Function:
return build('AWS::Lambda::Function', props, depends_on, deletion_policy, update_replace_policy, condition, metadata)
Attributes¶
Read-only values for get_att(logical_id, attribute). They are not accepted as inputs.
ArnSnapStartResponse