Class CfnFunction
The AWS::Lambda::Function
resource creates a Lambda function.
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CfnFunction : CfnResource, IInspectable, ITaggable
Syntax (vb)
Public Class CfnFunction
Inherits CfnResource
Implements IInspectable, ITaggable
Remarks
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.
See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
CloudformationResource: AWS::Lambda::Function
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;
var 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" },
LoggingConfig = new LoggingConfigProperty {
ApplicationLogLevel = "applicationLogLevel",
LogFormat = "logFormat",
LogGroup = "logGroup",
SystemLogLevel = "systemLogLevel"
},
MemorySize = 123,
PackageType = "packageType",
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"
} },
Timeout = 123,
TracingConfig = new TracingConfigProperty {
Mode = "mode"
},
VpcConfig = new VpcConfigProperty {
Ipv6AllowedForDualStack = false,
SecurityGroupIds = new [] { "securityGroupIds" },
SubnetIds = new [] { "subnetIds" }
}
});
Synopsis
Constructors
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 |
CfnFunction(Construct, String, ICfnFunctionProps) |
Properties
Architectures | The instruction set architecture that the function supports. |
AttrArn | The Amazon Resource Name (ARN) of the function. |
AttrSnapStartResponse | The function's SnapStart setting. |
AttrSnapStartResponseApplyOn | When set to |
AttrSnapStartResponseOptimizationStatus | When you provide a qualified Amazon Resource Name (ARN), this response element indicates whether SnapStart is activated for the specified function version. |
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 |
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 run your function. |
ImageConfig | Configuration values that override the container image Dockerfile settings. |
KmsKeyArn | The ARN of the AWS Key Management Service ( AWS KMS ) customer managed key that's used to encrypt your function's environment variables . When Lambda SnapStart is activated, Lambda also uses this key is to encrypt your function's snapshot. If you deploy your function using a container image, Lambda also uses this key to encrypt your function when it's deployed. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). If you don't provide a customer managed key, Lambda uses a default service key. |
Layers | A list of function layers to add to the function's execution environment. Specify each layer by its ARN, including the version. |
LoggingConfig | The function's Amazon CloudWatch Logs configuration settings. |
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. Note that new AWS accounts have reduced concurrency and memory quotas. AWS raises these quotas automatically based on your usage. You can also request a quota increase. |
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. |
RuntimeManagementConfig | Sets the runtime management configuration for a function's version. |
SnapStart | The function's AWS Lambda SnapStart setting. |
Tags | Tag Manager which manages the tags for this resource. |
TagsRaw | 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 |
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(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
CfnFunction(Construct, String, ICfnFunctionProps)
public CfnFunction(Construct scope, string id, ICfnFunctionProps props)
Parameters
- scope Constructs.Construct
Scope in which this resource is defined.
- id System.String
Construct identifier for this resource (unique in its scope).
- props ICfnFunctionProps
Resource properties.
Properties
Architectures
The instruction set architecture that the function supports.
public virtual string[] Architectures { get; set; }
Property Value
System.String[]
AttrArn
The Amazon Resource Name (ARN) of the function.
public virtual string AttrArn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: Arn
AttrSnapStartResponse
The function's SnapStart setting.
public virtual IResolvable AttrSnapStartResponse { get; }
Property Value
Remarks
CloudformationAttribute: SnapStartResponse
AttrSnapStartResponseApplyOn
When set to PublishedVersions
, Lambda creates a snapshot of the execution environment when you publish a function version.
public virtual string AttrSnapStartResponseApplyOn { get; }
Property Value
System.String
Remarks
CloudformationAttribute: SnapStartResponse.ApplyOn
AttrSnapStartResponseOptimizationStatus
When you provide a qualified Amazon Resource Name (ARN), this response element indicates whether SnapStart is activated for the specified function version.
public virtual string AttrSnapStartResponseOptimizationStatus { get; }
Property Value
System.String
Remarks
CloudformationAttribute: SnapStartResponse.OptimizationStatus
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
Code
The code for the function.
public virtual object Code { get; set; }
Property Value
System.Object
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
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
Description
A description of the function.
public virtual string Description { get; set; }
Property Value
System.String
Environment
Environment variables that are accessible from function code during execution.
public virtual object Environment { get; set; }
Property Value
System.Object
EphemeralStorage
The size of the function's /tmp
directory in MB.
public virtual object EphemeralStorage { get; set; }
Property Value
System.Object
FileSystemConfigs
Connection settings for an Amazon EFS file system.
public virtual object FileSystemConfigs { get; set; }
Property Value
System.Object
FunctionName
The name of the Lambda function, up to 64 characters in length.
public virtual string FunctionName { get; set; }
Property Value
System.String
Handler
The name of the method within your code that Lambda calls to run your function.
public virtual string Handler { get; set; }
Property Value
System.String
ImageConfig
Configuration values that override the container image Dockerfile settings.
public virtual object ImageConfig { get; set; }
Property Value
System.Object
KmsKeyArn
The ARN of the AWS Key Management Service ( AWS KMS ) customer managed key that's used to encrypt your function's environment variables . When Lambda SnapStart is activated, Lambda also uses this key is to encrypt your function's snapshot. If you deploy your function using a container image, Lambda also uses this key to encrypt your function when it's deployed. Note that this is not the same key that's used to protect your container image in the Amazon Elastic Container Registry (Amazon ECR). If you don't provide a customer managed key, Lambda uses a default service key.
public virtual string KmsKeyArn { get; set; }
Property Value
System.String
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[]
LoggingConfig
The function's Amazon CloudWatch Logs configuration settings.
public virtual object LoggingConfig { get; set; }
Property Value
System.Object
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. Note that new AWS accounts have reduced concurrency and memory quotas. AWS raises these quotas automatically based on your usage. You can also request a quota increase.
public virtual Nullable<double> MemorySize { get; set; }
Property Value
System.Nullable<System.Double>
PackageType
The type of deployment package.
public virtual string PackageType { get; set; }
Property Value
System.String
ReservedConcurrentExecutions
The number of simultaneous executions to reserve for the function.
public virtual Nullable<double> ReservedConcurrentExecutions { get; set; }
Property Value
System.Nullable<System.Double>
Role
The Amazon Resource Name (ARN) of the function's execution role.
public virtual string Role { get; set; }
Property Value
System.String
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
RuntimeManagementConfig
Sets the runtime management configuration for a function's version.
public virtual object RuntimeManagementConfig { get; set; }
Property Value
System.Object
SnapStart
The function's AWS Lambda SnapStart setting.
public virtual object SnapStart { get; set; }
Property Value
System.Object
Tags
Tag Manager which manages the tags for this resource.
public virtual TagManager Tags { get; }
Property Value
TagsRaw
A list of tags to apply to the function.
public virtual ICfnTag[] TagsRaw { get; set; }
Property Value
ICfnTag[]
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>
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
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
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>