CfnFunction

class aws_cdk.aws_lambda.CfnFunction(scope, id, *, code, role, architectures=None, code_signing_config_arn=None, dead_letter_config=None, description=None, environment=None, ephemeral_storage=None, file_system_configs=None, function_name=None, handler=None, image_config=None, kms_key_arn=None, layers=None, memory_size=None, package_type=None, reserved_concurrent_executions=None, runtime=None, tags=None, timeout=None, tracing_config=None, vpc_config=None)

Bases: aws_cdk.core.CfnResource

A CloudFormation AWS::Lambda::Function.

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 a container image, the code property must include the URI of a container image in the Amazon ECR registry. 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 a .zip file archive, the code property specifies the location of the .zip file. You must also specify the handler and runtime properties. For a Python example, see Deploy Python Lambda functions with .zip file archives .

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.

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.

CloudformationResource

AWS::Lambda::Function

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.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_version="s3ObjectVersion",
        zip_file="zipFile"
    ),
    role="role",

    # the properties below are optional
    architectures=["architectures"],
    code_signing_config_arn="codeSigningConfigArn",
    dead_letter_config=lambda.CfnFunction.DeadLetterConfigProperty(
        target_arn="targetArn"
    ),
    description="description",
    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"
    )],
    function_name="functionName",
    handler="handler",
    image_config=lambda.CfnFunction.ImageConfigProperty(
        command=["command"],
        entry_point=["entryPoint"],
        working_directory="workingDirectory"
    ),
    kms_key_arn="kmsKeyArn",
    layers=["layers"],
    memory_size=123,
    package_type="packageType",
    reserved_concurrent_executions=123,
    runtime="runtime",
    tags=[CfnTag(
        key="key",
        value="value"
    )],
    timeout=123,
    tracing_config=lambda.CfnFunction.TracingConfigProperty(
        mode="mode"
    ),
    vpc_config=lambda.CfnFunction.VpcConfigProperty(
        security_group_ids=["securityGroupIds"],
        subnet_ids=["subnetIds"]
    )
)

Create a new AWS::Lambda::Function.

Parameters
  • scope (Construct) –

    • scope in which this resource is defined.

  • id (str) –

    • scoped id of the resource.

  • code (Union[IResolvable, CodeProperty, Dict[str, Any]]) – The code for the function.

  • role (str) – The Amazon Resource Name (ARN) of the function’s execution role.

  • architectures (Optional[Sequence[str]]) – The instruction set architecture that the function supports. Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64 .

  • code_signing_config_arn (Optional[str]) – To enable code signing for this function, specify the ARN of a code-signing configuration. A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.

  • dead_letter_config (Union[IResolvable, DeadLetterConfigProperty, Dict[str, Any], None]) – A dead letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing. For more information, see Dead Letter Queues .

  • description (Optional[str]) – A description of the function.

  • environment (Union[IResolvable, EnvironmentProperty, Dict[str, Any], None]) – Environment variables that are accessible from function code during execution.

  • ephemeral_storage (Union[IResolvable, EphemeralStorageProperty, Dict[str, Any], None]) – The size of the function’s /tmp directory in MB. The default value is 512, but can be any whole number between 512 and 10240 MB.

  • file_system_configs (Union[IResolvable, Sequence[Union[IResolvable, FileSystemConfigProperty, Dict[str, Any]]], None]) – Connection settings for an Amazon EFS file system. 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 .

  • function_name (Optional[str]) – The name of the Lambda function, up to 64 characters in length. If you don’t specify a name, AWS 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.

  • handler (Optional[str]) – The name of the method within your code that Lambda calls to execute your function. 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 Programming Model .

  • image_config (Union[IResolvable, ImageConfigProperty, Dict[str, Any], None]) – Configuration values that override the container image Dockerfile settings. See Container settings .

  • kms_key_arn (Optional[str]) – The ARN of the AWS Key Management Service ( AWS KMS ) key that’s used to encrypt your function’s environment variables. If it’s not provided, AWS Lambda uses a default service key.

  • layers (Optional[Sequence[str]]) – A list of function layers to add to the function’s execution environment. Specify each layer by its ARN, including the version.

  • memory_size (Union[int, float, None]) – The amount of memory available to the function at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB.

  • package_type (Optional[str]) – The type of deployment package. Set to Image for container image and set Zip for .zip file archive.

  • reserved_concurrent_executions (Union[int, float, None]) – The number of simultaneous executions to reserve for the function.

  • runtime (Optional[str]) – The identifier of the function’s runtime . Runtime is required if the deployment package is a .zip file archive.

  • tags (Optional[Sequence[Union[CfnTag, Dict[str, Any]]]]) – A list of tags to apply to the function.

  • timeout (Union[int, float, None]) – The amount of time (in seconds) that Lambda allows a function to run before stopping it. The default is 3 seconds. The maximum allowed value is 900 seconds. For additional information, see Lambda execution environment .

  • tracing_config (Union[IResolvable, TracingConfigProperty, Dict[str, Any], None]) – Set Mode to Active to sample and trace a subset of incoming requests with X-Ray .

  • vpc_config (Union[IResolvable, VpcConfigProperty, Dict[str, Any], None]) – For network connectivity to AWS resources in a VPC , specify a list of security groups and subnets in the VPC.

Methods

add_deletion_override(path)

Syntactic sugar for addOverride(path, undefined).

Parameters

path (str) – The path of the value to delete.

Return type

None

add_depends_on(target)

Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.

This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.

Parameters

target (CfnResource) –

Return type

None

add_metadata(key, value)

Add a value to the CloudFormation Resource Metadata.

Parameters
  • key (str) –

  • value (Any) –

See

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

Return type

None

add_override(path, value)

Adds an override to the synthesized CloudFormation resource.

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:

cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"])
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")

would add the overrides Example:

"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
  • path (str) –

    • The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.

  • value (Any) –

    • The value. Could be primitive or complex.

Return type

None

add_property_deletion_override(property_path)

Adds an override that deletes the value of a property from the resource definition.

Parameters

property_path (str) – The path to the property.

Return type

None

add_property_override(property_path, value)

Adds an override to a resource property.

Syntactic sugar for addOverride("Properties.<...>", value).

Parameters
  • property_path (str) – The path of the property.

  • value (Any) – The value.

Return type

None

apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)

Sets the deletion policy of the resource based on the removal policy specified.

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).

Parameters
  • policy (Optional[RemovalPolicy]) –

  • apply_to_update_replace_policy (Optional[bool]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: true

  • default (Optional[RemovalPolicy]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.

Return type

None

get_att(attribute_name)

Returns a token for an runtime attribute of this resource.

Ideally, use generated attribute accessors (e.g. resource.arn), but this can be used for future compatibility in case there is no generated attribute.

Parameters

attribute_name (str) – The name of the attribute.

Return type

Reference

get_metadata(key)

Retrieve a value value from the CloudFormation Resource Metadata.

Parameters

key (str) –

See

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html

Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.

Return type

Any

inspect(inspector)

Examines the CloudFormation resource and discloses attributes.

Parameters

inspector (TreeInspector) –

  • tree inspector to collect and process attributes.

Return type

None

override_logical_id(new_logical_id)

Overrides the auto-generated logical ID with a specific ID.

Parameters

new_logical_id (str) – The new logical ID to use for this stack element.

Return type

None

to_string()

Returns a string representation of this construct.

Return type

str

Returns

a string representation of this resource

Attributes

CFN_RESOURCE_TYPE_NAME = 'AWS::Lambda::Function'
architectures

The instruction set architecture that the function supports.

Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-architectures

Return type

Optional[List[str]]

attr_arn

The Amazon Resource Name (ARN) of the function.

CloudformationAttribute

Arn

Return type

str

cfn_options

Options for this resource, such as condition, update policy etc.

Return type

ICfnResourceOptions

cfn_resource_type

AWS resource type.

Return type

str

code

The code for the function.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-code

Return type

Union[IResolvable, CodeProperty]

code_signing_config_arn

To enable code signing for this function, specify the ARN of a code-signing configuration.

A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-codesigningconfigarn

Return type

Optional[str]

creation_stack

return:

the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.

Return type

List[str]

dead_letter_config

A dead letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.

For more information, see Dead Letter Queues .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-deadletterconfig

Return type

Union[IResolvable, DeadLetterConfigProperty, None]

description

A description of the function.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description

Return type

Optional[str]

environment

Environment variables that are accessible from function code during execution.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-environment

Return type

Union[IResolvable, EnvironmentProperty, None]

ephemeral_storage

The size of the function’s /tmp directory in MB.

The default value is 512, but can be any whole number between 512 and 10240 MB.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-ephemeralstorage

Return type

Union[IResolvable, EphemeralStorageProperty, None]

file_system_configs

Connection settings for an Amazon EFS file system.

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 .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-filesystemconfigs

Return type

Union[IResolvable, List[Union[IResolvable, FileSystemConfigProperty]], None]

function_name

The name of the Lambda function, up to 64 characters in length.

If you don’t specify a name, AWS 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.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionname

Return type

Optional[str]

handler

The name of the method within your code that Lambda calls to execute your function.

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 Programming Model .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-handler

Return type

Optional[str]

image_config

Configuration values that override the container image Dockerfile settings.

See Container settings .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-imageconfig

Return type

Union[IResolvable, ImageConfigProperty, None]

kms_key_arn

The ARN of the AWS Key Management Service ( AWS KMS ) key that’s used to encrypt your function’s environment variables.

If it’s not provided, AWS Lambda uses a default service key.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-kmskeyarn

Return type

Optional[str]

layers

//docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html>`_ to add to the function’s execution environment. Specify each layer by its ARN, including the version.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-layers

Type

A list of `function layers <https

Return type

Optional[List[str]]

logical_id

The logical ID for this CloudFormation stack element.

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).

Return type

str

Returns

the logical ID as a stringified token. This value will only get resolved during synthesis.

memory_size

//docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html>`_ at runtime. Increasing the function memory also increases its CPU allocation. The default value is 128 MB. The value can be any multiple of 1 MB.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-memorysize

Type

The amount of `memory available to the function <https

Return type

Union[int, float, None]

node

The construct tree node associated with this construct.

Return type

ConstructNode

package_type

The type of deployment package.

Set to Image for container image and set Zip for .zip file archive.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-packagetype

Return type

Optional[str]

ref

Return a string that will be resolved to a CloudFormation { Ref } for this element.

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 }).

Return type

str

reserved_concurrent_executions

The number of simultaneous executions to reserve for the function.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-reservedconcurrentexecutions

Return type

Union[int, float, None]

role

The Amazon Resource Name (ARN) of the function’s execution role.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-role

Return type

str

runtime

//docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html>`_ . Runtime is required if the deployment package is a .zip file archive.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-runtime

Type

The identifier of the function’s `runtime <https

Return type

Optional[str]

stack

The stack in which this element is defined.

CfnElements must be defined within a stack scope (directly or indirectly).

Return type

Stack

tags

//docs.aws.amazon.com/lambda/latest/dg/tagging.html>`_ to apply to the function.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tags

Type

A list of `tags <https

Return type

TagManager

timeout

The amount of time (in seconds) that Lambda allows a function to run before stopping it.

The default is 3 seconds. The maximum allowed value is 900 seconds. For additional information, see Lambda execution environment .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-timeout

Return type

Union[int, float, None]

tracing_config

//docs.aws.amazon.com/lambda/latest/dg/services-xray.html>`_ .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-tracingconfig

Type

Set Mode to Active to sample and trace a subset of incoming requests with `X-Ray <https

Return type

Union[IResolvable, TracingConfigProperty, None]

vpc_config

//docs.aws.amazon.com/lambda/latest/dg/configuration-network.html>`_ , specify a list of security groups and subnets in the VPC.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-vpcconfig

Type

For network connectivity to AWS resources in a `VPC <https

Return type

Union[IResolvable, VpcConfigProperty, None]

Static Methods

classmethod is_cfn_element(x)

Returns true if a construct is a stack element (i.e. part of the synthesized cloudformation template).

Uses duck-typing instead of instanceof to allow stack elements from different versions of this library to be included in the same stack.

Parameters

x (Any) –

Return type

bool

Returns

The construct as a stack element or undefined if it is not a stack element.

classmethod is_cfn_resource(construct)

Check whether the given construct is a CfnResource.

Parameters

construct (IConstruct) –

Return type

bool

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool

CodeProperty

class CfnFunction.CodeProperty(*, image_uri=None, s3_bucket=None, s3_key=None, s3_object_version=None, zip_file=None)

Bases: object

The deployment package for a Lambda function. To deploy a function defined as a container image, you specify the location of a container image in the Amazon ECR registry. For a .zip file deployment package, you can specify the location of an object in Amazon S3. For Node.js and Python functions, you can specify the function code inline in the template.

Changes to a deployment package in Amazon S3 are not detected automatically during stack updates. To update the function code, change the object key or version in the template.

Parameters
  • image_uri (Optional[str]) –

    URI of a container image in the Amazon ECR registry.

  • s3_bucket (Optional[str]) – An Amazon S3 bucket in the same AWS Region as your function. The bucket can be in a different AWS account.

  • s3_key (Optional[str]) – The Amazon S3 key of the deployment package.

  • s3_object_version (Optional[str]) – For versioned objects, the version of the deployment package object to use.

  • zip_file (Optional[str]) –

    (Node.js and Python) The source code of your Lambda function. If you include your function source inline with this parameter, AWS CloudFormation places it in a file named index and zips it to create a deployment package . This zip file cannot exceed 4MB. For the Handler property, the first part of the handler identifier must be index . For example, index.handler . For JSON, you must escape quotes and special characters such as newline ( \n ) with a backslash. If you specify a function that interacts with an AWS CloudFormation custom resource, you don’t have to write your own functions to send responses to the custom resource that invoked the function. AWS CloudFormation provides a response module ( cfn-response ) that simplifies sending responses. See Using AWS Lambda with AWS CloudFormation for details.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

code_property = lambda.CfnFunction.CodeProperty(
    image_uri="imageUri",
    s3_bucket="s3Bucket",
    s3_key="s3Key",
    s3_object_version="s3ObjectVersion",
    zip_file="zipFile"
)

Attributes

image_uri

//docs.aws.amazon.com/lambda/latest/dg/lambda-images.html>`_ in the Amazon ECR registry.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-imageuri

Type

URI of a `container image <https

Return type

Optional[str]

s3_bucket

An Amazon S3 bucket in the same AWS Region as your function.

The bucket can be in a different AWS account.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3bucket

Return type

Optional[str]

s3_key

The Amazon S3 key of the deployment package.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key

Return type

Optional[str]

s3_object_version

For versioned objects, the version of the deployment package object to use.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectversion

Return type

Optional[str]

zip_file

//docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html>`_ . This zip file cannot exceed 4MB. For the Handler property, the first part of the handler identifier must be index . For example, index.handler .

For JSON, you must escape quotes and special characters such as newline ( \n ) with a backslash.

If you specify a function that interacts with an AWS CloudFormation custom resource, you don’t have to write your own functions to send responses to the custom resource that invoked the function. AWS CloudFormation provides a response module ( cfn-response ) that simplifies sending responses. See Using AWS Lambda with AWS CloudFormation for details.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-zipfile

Type

(Node.js and Python) The source code of your Lambda function. If you include your function source inline with this parameter, AWS CloudFormation places it in a file named index and zips it to create a `deployment package <https

Return type

Optional[str]

DeadLetterConfigProperty

class CfnFunction.DeadLetterConfigProperty(*, target_arn=None)

Bases: object

The dead-letter queue for failed asynchronous invocations.

Parameters

target_arn (Optional[str]) – The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

dead_letter_config_property = lambda.CfnFunction.DeadLetterConfigProperty(
    target_arn="targetArn"
)

Attributes

target_arn

The Amazon Resource Name (ARN) of an Amazon SQS queue or Amazon SNS topic.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-deadletterconfig.html#cfn-lambda-function-deadletterconfig-targetarn

Return type

Optional[str]

EnvironmentProperty

class CfnFunction.EnvironmentProperty(*, variables=None)

Bases: object

A function’s environment variable settings.

You can use environment variables to adjust your function’s behavior without updating code. An environment variable is a pair of strings that are stored in a function’s version-specific configuration.

Parameters

variables (Union[IResolvable, Mapping[str, str], None]) – Environment variable key-value pairs. For more information, see Using Lambda environment variables .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

environment_property = lambda.CfnFunction.EnvironmentProperty(
    variables={
        "variables_key": "variables"
    }
)

Attributes

variables

Environment variable key-value pairs.

For more information, see Using Lambda environment variables .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-environment.html#cfn-lambda-function-environment-variables

Return type

Union[IResolvable, Mapping[str, str], None]

EphemeralStorageProperty

class CfnFunction.EphemeralStorageProperty(*, size)

Bases: object

The size of the function’s /tmp directory in MB.

The default value is 512, but can be any whole number between 512 and 10240 MB.

Parameters

size (Union[int, float]) – The size of the function’s /tmp directory.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-ephemeralstorage.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

ephemeral_storage_property = lambda.CfnFunction.EphemeralStorageProperty(
    size=123
)

Attributes

size

The size of the function’s /tmp directory.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-ephemeralstorage.html#cfn-lambda-function-ephemeralstorage-size

Return type

Union[int, float]

FileSystemConfigProperty

class CfnFunction.FileSystemConfigProperty(*, arn, local_mount_path)

Bases: object

Details about the connection between a Lambda function and an Amazon EFS file system .

Parameters
  • arn (str) – The Amazon Resource Name (ARN) of the Amazon EFS access point that provides access to the file system.

  • local_mount_path (str) – The path where the function can access the file system, starting with /mnt/ .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

file_system_config_property = lambda.CfnFunction.FileSystemConfigProperty(
    arn="arn",
    local_mount_path="localMountPath"
)

Attributes

arn

The Amazon Resource Name (ARN) of the Amazon EFS access point that provides access to the file system.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html#cfn-lambda-function-filesystemconfig-arn

Return type

str

local_mount_path

The path where the function can access the file system, starting with /mnt/ .

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-filesystemconfig.html#cfn-lambda-function-filesystemconfig-localmountpath

Return type

str

ImageConfigProperty

class CfnFunction.ImageConfigProperty(*, command=None, entry_point=None, working_directory=None)

Bases: object

Configuration values that override the container image Dockerfile settings.

See Container settings .

Parameters
  • command (Optional[Sequence[str]]) – Specifies parameters that you want to pass in with ENTRYPOINT.

  • entry_point (Optional[Sequence[str]]) – Specifies the entry point to their application, which is typically the location of the runtime executable.

  • working_directory (Optional[str]) – Specifies the working directory.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-imageconfig.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

image_config_property = lambda.CfnFunction.ImageConfigProperty(
    command=["command"],
    entry_point=["entryPoint"],
    working_directory="workingDirectory"
)

Attributes

command

Specifies parameters that you want to pass in with ENTRYPOINT.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-imageconfig.html#cfn-lambda-function-imageconfig-command

Return type

Optional[List[str]]

entry_point

Specifies the entry point to their application, which is typically the location of the runtime executable.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-imageconfig.html#cfn-lambda-function-imageconfig-entrypoint

Return type

Optional[List[str]]

working_directory

Specifies the working directory.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-imageconfig.html#cfn-lambda-function-imageconfig-workingdirectory

Return type

Optional[str]

TracingConfigProperty

class CfnFunction.TracingConfigProperty(*, mode=None)

Bases: object

The function’s AWS X-Ray tracing configuration. To sample and record incoming requests, set Mode to Active .

Parameters

mode (Optional[str]) – The tracing mode.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-tracingconfig.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

tracing_config_property = lambda.CfnFunction.TracingConfigProperty(
    mode="mode"
)

Attributes

mode

The tracing mode.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-tracingconfig.html#cfn-lambda-function-tracingconfig-mode

Return type

Optional[str]

VpcConfigProperty

class CfnFunction.VpcConfigProperty(*, security_group_ids=None, subnet_ids=None)

Bases: object

The VPC security groups and subnets that are attached to a Lambda function.

When you connect a function to a VPC, Lambda creates an elastic network interface for each combination of security group and subnet in the function’s VPC configuration. The function can only access resources and the internet through that VPC. For more information, see VPC Settings . .. epigraph:

When you delete a function, AWS CloudFormation monitors the state of its network interfaces and waits for Lambda to delete them before proceeding. If the VPC is defined in the same stack, the network interfaces need to be deleted by Lambda before AWS CloudFormation can delete the VPC's resources.

To monitor network interfaces, AWS CloudFormation needs the ``ec2:DescribeNetworkInterfaces`` permission. It obtains this from the user or role that modifies the stack. If you don't provide this permission, AWS CloudFormation does not wait for network interfaces to be deleted.
Parameters
  • security_group_ids (Optional[Sequence[str]]) – A list of VPC security groups IDs.

  • subnet_ids (Optional[Sequence[str]]) – A list of VPC subnet IDs.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_lambda as lambda_

vpc_config_property = lambda.CfnFunction.VpcConfigProperty(
    security_group_ids=["securityGroupIds"],
    subnet_ids=["subnetIds"]
)

Attributes

security_group_ids

A list of VPC security groups IDs.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html#cfn-lambda-function-vpcconfig-securitygroupids

Return type

Optional[List[str]]

subnet_ids

A list of VPC subnet IDs.

Link

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-vpcconfig.html#cfn-lambda-function-vpcconfig-subnetids

Return type

Optional[List[str]]