CfnFunctionProps

class aws_cdk.aws_lambda.CfnFunctionProps(*, code, role, architectures=None, code_signing_config_arn=None, dead_letter_config=None, description=None, environment=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: object

Properties for defining a CfnFunction.

Parameters
  • code (Union[IResolvable, CodeProperty]) – 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, 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, None]) – Environment variables that are accessible from function code during execution.

  • file_system_configs (Union[IResolvable, Sequence[Union[IResolvable, FileSystemConfigProperty]], 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, 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[CfnTag]]) – 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, None]) – Set Mode to Active to sample and trace a subset of incoming requests with X-Ray .

  • vpc_config (Union[IResolvable, VpcConfigProperty, None]) – For network connectivity to AWS resources in a VPC , 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

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_props = lambda.CfnFunctionProps(
    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"
        }
    ),
    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"]
    )
)

Attributes

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]]

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]

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]

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]]

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]

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]

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]

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

Optional[List[CfnTag]]

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]