Show / Hide Table of Contents

Class CfnFunction

A CloudFormation AWS::Lambda::Function.

Inheritance
System.Object
Construct
CfnElement
CfnRefElement
CfnResource
CfnFunction
Implements
IConstruct
Constructs.IConstruct
IDependable
IInspectable
Inherited Members
CfnResource.IsCfnResource(IConstruct)
CfnResource.AddDeletionOverride(String)
CfnResource.AddDependsOn(CfnResource)
CfnResource.AddMetadata(String, Object)
CfnResource.AddOverride(String, Object)
CfnResource.AddPropertyDeletionOverride(String)
CfnResource.AddPropertyOverride(String, Object)
CfnResource.ApplyRemovalPolicy(Nullable<RemovalPolicy>, IRemovalPolicyOptions)
CfnResource.GetAtt(String)
CfnResource.GetMetadata(String)
CfnResource.ShouldSynthesize()
CfnResource.ToString()
CfnResource.ValidateProperties(Object)
CfnResource.CfnOptions
CfnResource.CfnResourceType
CfnResource.UpdatedProperites
CfnRefElement.Ref
CfnElement.IsCfnElement(Object)
CfnElement.OverrideLogicalId(String)
CfnElement.CreationStack
CfnElement.LogicalId
CfnElement.Stack
Construct.IsConstruct(Object)
Construct.OnPrepare()
Construct.OnSynthesize(ISynthesisSession)
Construct.OnValidate()
Construct.Prepare()
Construct.Synthesize(ISynthesisSession)
Construct.Validate()
Construct.Node
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.AWS.Lambda.dll
Syntax (csharp)
public class CfnFunction : CfnResource, IConstruct, IConstruct, IDependable, IInspectable
Syntax (vb)
Public Class CfnFunction
    Inherits CfnResource
    Implements IConstruct, IConstruct, IDependable, IInspectable
Remarks

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

Examples
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Lambda;

CfnFunction cfnFunction = new CfnFunction(this, "MyCfnFunction", new CfnFunctionProps {
    Code = new CodeProperty {
        ImageUri = "imageUri",
        S3Bucket = "s3Bucket",
        S3Key = "s3Key",
        S3ObjectVersion = "s3ObjectVersion",
        ZipFile = "zipFile"
    },
    Role = "role",

    // the properties below are optional
    Architectures = new [] { "architectures" },
    CodeSigningConfigArn = "codeSigningConfigArn",
    DeadLetterConfig = new DeadLetterConfigProperty {
        TargetArn = "targetArn"
    },
    Description = "description",
    Environment = new EnvironmentProperty {
        Variables = new Dictionary<string, string> {
            { "variablesKey", "variables" }
        }
    },
    EphemeralStorage = new EphemeralStorageProperty {
        Size = 123
    },
    FileSystemConfigs = new [] { new FileSystemConfigProperty {
        Arn = "arn",
        LocalMountPath = "localMountPath"
    } },
    FunctionName = "functionName",
    Handler = "handler",
    ImageConfig = new ImageConfigProperty {
        Command = new [] { "command" },
        EntryPoint = new [] { "entryPoint" },
        WorkingDirectory = "workingDirectory"
    },
    KmsKeyArn = "kmsKeyArn",
    Layers = new [] { "layers" },
    MemorySize = 123,
    PackageType = "packageType",
    ReservedConcurrentExecutions = 123,
    Runtime = "runtime",
    Tags = new [] { new CfnTag {
        Key = "key",
        Value = "value"
    } },
    Timeout = 123,
    TracingConfig = new TracingConfigProperty {
        Mode = "mode"
    },
    VpcConfig = new VpcConfigProperty {
        SecurityGroupIds = new [] { "securityGroupIds" },
        SubnetIds = new [] { "subnetIds" }
    }
});

Synopsis

Constructors

CfnFunction(Construct, String, ICfnFunctionProps)

Create a new AWS::Lambda::Function.

CfnFunction(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

CfnFunction(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Properties

Architectures

The instruction set architecture that the function supports.

AttrArn

The Amazon Resource Name (ARN) of the function.

CFN_RESOURCE_TYPE_NAME

The CloudFormation resource type name for this resource class.

CfnProperties
Code

The code for the function.

CodeSigningConfigArn

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

DeadLetterConfig

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

Description

A description of the function.

Environment

Environment variables that are accessible from function code during execution.

EphemeralStorage

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

FileSystemConfigs

Connection settings for an Amazon EFS file system.

FunctionName

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

Handler

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

ImageConfig

Configuration values that override the container image Dockerfile settings.

KmsKeyArn

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

Layers

A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.

MemorySize

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.

PackageType

The type of deployment package.

ReservedConcurrentExecutions

The number of simultaneous executions to reserve for the function.

Role

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

Runtime

The identifier of the function's runtime . Runtime is required if the deployment package is a .zip file archive.

Tags

A list of tags to apply to the function.

Timeout

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

TracingConfig

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

VpcConfig

For network connectivity to AWS resources in a VPC , specify a list of security groups and subnets in the VPC.

Methods

Inspect(TreeInspector)

Examines the CloudFormation resource and discloses attributes.

RenderProperties(IDictionary<String, Object>)

Constructors

CfnFunction(Construct, String, ICfnFunctionProps)

Create a new AWS::Lambda::Function.

public CfnFunction(Construct scope, string id, ICfnFunctionProps props)
Parameters
scope Construct
  • scope in which this resource is defined.
id System.String
  • scoped id of the resource.
props ICfnFunctionProps
  • resource properties.

CfnFunction(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected CfnFunction(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

CfnFunction(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected CfnFunction(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Properties

Architectures

The instruction set architecture that the function supports.

public virtual string[] Architectures { get; set; }
Property Value

System.String[]

Remarks

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

AttrArn

The Amazon Resource Name (ARN) of the function.

public virtual string AttrArn { get; }
Property Value

System.String

Remarks

CloudformationAttribute: Arn

CFN_RESOURCE_TYPE_NAME

The CloudFormation resource type name for this resource class.

public static string CFN_RESOURCE_TYPE_NAME { get; }
Property Value

System.String

CfnProperties

protected override IDictionary<string, object> CfnProperties { get; }
Property Value

System.Collections.Generic.IDictionary<System.String, System.Object>

Overrides
CfnResource.CfnProperties

Code

The code for the function.

public virtual object Code { get; set; }
Property Value

System.Object

Remarks

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

CodeSigningConfigArn

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

public virtual string CodeSigningConfigArn { get; set; }
Property Value

System.String

Remarks

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

DeadLetterConfig

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

public virtual object DeadLetterConfig { get; set; }
Property Value

System.Object

Remarks

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

Description

A description of the function.

public virtual string Description { get; set; }
Property Value

System.String

Remarks

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

Environment

Environment variables that are accessible from function code during execution.

public virtual object Environment { get; set; }
Property Value

System.Object

Remarks

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

EphemeralStorage

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

public virtual object EphemeralStorage { get; set; }
Property Value

System.Object

Remarks

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

FileSystemConfigs

Connection settings for an Amazon EFS file system.

public virtual object FileSystemConfigs { get; set; }
Property Value

System.Object

Remarks

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

FunctionName

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

public virtual string FunctionName { get; set; }
Property Value

System.String

Remarks

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

Handler

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

public virtual string Handler { get; set; }
Property Value

System.String

Remarks

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

ImageConfig

Configuration values that override the container image Dockerfile settings.

public virtual object ImageConfig { get; set; }
Property Value

System.Object

Remarks

See Container settings .

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

KmsKeyArn

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

public virtual string KmsKeyArn { get; set; }
Property Value

System.String

Remarks

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

Layers

A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version.

public virtual string[] Layers { get; set; }
Property Value

System.String[]

Remarks

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

MemorySize

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.

public virtual Nullable<double> MemorySize { get; set; }
Property Value

System.Nullable<System.Double>

Remarks

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

PackageType

The type of deployment package.

public virtual string PackageType { get; set; }
Property Value

System.String

Remarks

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

ReservedConcurrentExecutions

The number of simultaneous executions to reserve for the function.

public virtual Nullable<double> ReservedConcurrentExecutions { get; set; }
Property Value

System.Nullable<System.Double>

Remarks

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

Role

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

public virtual string Role { get; set; }
Property Value

System.String

Remarks

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

Runtime

The identifier of the function's runtime . Runtime is required if the deployment package is a .zip file archive.

public virtual string Runtime { get; set; }
Property Value

System.String

Remarks

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

Tags

A list of tags to apply to the function.

public virtual TagManager Tags { get; }
Property Value

TagManager

Remarks

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

Timeout

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

public virtual Nullable<double> Timeout { get; set; }
Property Value

System.Nullable<System.Double>

Remarks

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

TracingConfig

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

public virtual object TracingConfig { get; set; }
Property Value

System.Object

Remarks

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

VpcConfig

For network connectivity to AWS resources in a VPC , specify a list of security groups and subnets in the VPC.

public virtual object VpcConfig { get; set; }
Property Value

System.Object

Remarks

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

Methods

Inspect(TreeInspector)

Examines the CloudFormation resource and discloses attributes.

public virtual void Inspect(TreeInspector inspector)
Parameters
inspector TreeInspector
  • tree inspector to collect and process attributes.

RenderProperties(IDictionary<String, Object>)

protected override IDictionary<string, object> RenderProperties(IDictionary<string, object> props)
Parameters
props System.Collections.Generic.IDictionary<System.String, System.Object>
Returns

System.Collections.Generic.IDictionary<System.String, System.Object>

Overrides
CfnResource.RenderProperties(IDictionary<String, Object>)

Implements

IConstruct
Constructs.IConstruct
IDependable
IInspectable
Back to top Generated by DocFX