@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:44.059Z") public class CfnFunction extends CfnResource implements IInspectable
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.
Example:
// The code below shows an example of how to instantiate this type. // The values are placeholders you should change. import software.amazon.awscdk.services.lambda.*; CfnFunction cfnFunction = CfnFunction.Builder.create(this, "MyCfnFunction") .code(CodeProperty.builder() .imageUri("imageUri") .s3Bucket("s3Bucket") .s3Key("s3Key") .s3ObjectVersion("s3ObjectVersion") .zipFile("zipFile") .build()) .role("role") // the properties below are optional .architectures(List.of("architectures")) .codeSigningConfigArn("codeSigningConfigArn") .deadLetterConfig(DeadLetterConfigProperty.builder() .targetArn("targetArn") .build()) .description("description") .environment(EnvironmentProperty.builder() .variables(Map.of( "variablesKey", "variables")) .build()) .ephemeralStorage(EphemeralStorageProperty.builder() .size(123) .build()) .fileSystemConfigs(List.of(FileSystemConfigProperty.builder() .arn("arn") .localMountPath("localMountPath") .build())) .functionName("functionName") .handler("handler") .imageConfig(ImageConfigProperty.builder() .command(List.of("command")) .entryPoint(List.of("entryPoint")) .workingDirectory("workingDirectory") .build()) .kmsKeyArn("kmsKeyArn") .layers(List.of("layers")) .memorySize(123) .packageType("packageType") .reservedConcurrentExecutions(123) .runtime("runtime") .runtimeManagementConfig(RuntimeManagementConfigProperty.builder() .updateRuntimeOn("updateRuntimeOn") // the properties below are optional .runtimeVersionArn("runtimeVersionArn") .build()) .snapStart(SnapStartProperty.builder() .applyOn("applyOn") .build()) .tags(List.of(CfnTag.builder() .key("key") .value("value") .build())) .timeout(123) .tracingConfig(TracingConfigProperty.builder() .mode("mode") .build()) .vpcConfig(VpcConfigProperty.builder() .securityGroupIds(List.of("securityGroupIds")) .subnetIds(List.of("subnetIds")) .build()) .build();
Modifier and Type | Class and Description |
---|---|
static class |
CfnFunction.Builder
A fluent builder for
CfnFunction . |
static interface |
CfnFunction.CodeProperty
The [deployment package](https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-package.html) for a Lambda function.
|
static interface |
CfnFunction.DeadLetterConfigProperty
The [dead-letter queue](https://docs.aws.amazon.com/lambda/latest/dg/invocation-async.html#dlq) for failed asynchronous invocations.
|
static interface |
CfnFunction.EnvironmentProperty
A function's environment variable settings.
|
static interface |
CfnFunction.EphemeralStorageProperty
The size of the function's `/tmp` directory in MB.
|
static interface |
CfnFunction.FileSystemConfigProperty
Details about the connection between a Lambda function and an [Amazon EFS file system](https://docs.aws.amazon.com/lambda/latest/dg/configuration-filesystem.html) .
|
static interface |
CfnFunction.ImageConfigProperty
Configuration values that override the container image Dockerfile settings.
|
static interface |
CfnFunction.RuntimeManagementConfigProperty
Sets the runtime management configuration for a function's version.
|
static interface |
CfnFunction.SnapStartProperty
The function's [AWS Lambda SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting.
|
static interface |
CfnFunction.SnapStartResponseProperty
Example:
|
static interface |
CfnFunction.TracingConfigProperty
The function's [AWS X-Ray](https://docs.aws.amazon.com/lambda/latest/dg/services-xray.html) tracing configuration.
|
static interface |
CfnFunction.VpcConfigProperty
The VPC security groups and subnets that are attached to a Lambda function.
|
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
IConstruct.Jsii$Default
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnFunction(Construct scope,
java.lang.String id,
CfnFunctionProps props)
Create a new `AWS::Lambda::Function`.
|
protected |
CfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CfnFunction(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.String> |
getArchitectures()
The instruction set architecture that the function supports.
|
java.lang.String |
getAttrArn()
The Amazon Resource Name (ARN) of the function.
|
java.lang.String |
getAttrSnapStartResponseApplyOn() |
java.lang.String |
getAttrSnapStartResponseOptimizationStatus() |
protected java.util.Map<java.lang.String,java.lang.Object> |
getCfnProperties() |
java.lang.Object |
getCode()
The code for the function.
|
java.lang.String |
getCodeSigningConfigArn()
To enable code signing for this function, specify the ARN of a code-signing configuration.
|
java.lang.Object |
getDeadLetterConfig()
A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.
|
java.lang.String |
getDescription()
A description of the function.
|
java.lang.Object |
getEnvironment()
Environment variables that are accessible from function code during execution.
|
java.lang.Object |
getEphemeralStorage()
The size of the function's `/tmp` directory in MB.
|
java.lang.Object |
getFileSystemConfigs()
Connection settings for an Amazon EFS file system.
|
java.lang.String |
getFunctionName()
The name of the Lambda function, up to 64 characters in length.
|
java.lang.String |
getHandler()
The name of the method within your code that Lambda calls to run your function.
|
java.lang.Object |
getImageConfig()
Configuration values that override the container image Dockerfile settings.
|
java.lang.String |
getKmsKeyArn()
The ARN of the AWS Key Management Service ( AWS KMS ) customer managed key that's used to encrypt your function's [environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption) .
|
java.util.List<java.lang.String> |
getLayers()
A list of [function layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) to add to the function's execution environment.
|
java.lang.Number |
getMemorySize()
The amount of [memory available to the function](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console) at runtime.
|
java.lang.String |
getPackageType()
The type of deployment package.
|
java.lang.Number |
getReservedConcurrentExecutions()
The number of simultaneous executions to reserve for the function.
|
java.lang.String |
getRole()
The Amazon Resource Name (ARN) of the function's execution role.
|
java.lang.String |
getRuntime()
The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) .
|
java.lang.Object |
getRuntimeManagementConfig()
Sets the runtime management configuration for a function's version.
|
java.lang.Object |
getSnapStart()
The function's [AWS Lambda SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting.
|
TagManager |
getTags()
A list of [tags](https://docs.aws.amazon.com/lambda/latest/dg/tagging.html) to apply to the function.
|
java.lang.Number |
getTimeout()
The amount of time (in seconds) that Lambda allows a function to run before stopping it.
|
java.lang.Object |
getTracingConfig()
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) .
|
java.lang.Object |
getVpcConfig()
For network connectivity to AWS resources in a [VPC](https://docs.aws.amazon.com/lambda/latest/dg/configuration-network.html) , specify a list of security groups and subnets in the VPC.
|
void |
inspect(TreeInspector inspector)
Examines the CloudFormation resource and discloses attributes.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
renderProperties(java.util.Map<java.lang.String,java.lang.Object> props) |
void |
setArchitectures(java.util.List<java.lang.String> value)
The instruction set architecture that the function supports.
|
void |
setCode(CfnFunction.CodeProperty value)
The code for the function.
|
void |
setCode(IResolvable value)
The code for the function.
|
void |
setCodeSigningConfigArn(java.lang.String value)
To enable code signing for this function, specify the ARN of a code-signing configuration.
|
void |
setDeadLetterConfig(CfnFunction.DeadLetterConfigProperty value)
A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.
|
void |
setDeadLetterConfig(IResolvable value)
A dead-letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.
|
void |
setDescription(java.lang.String value)
A description of the function.
|
void |
setEnvironment(CfnFunction.EnvironmentProperty value)
Environment variables that are accessible from function code during execution.
|
void |
setEnvironment(IResolvable value)
Environment variables that are accessible from function code during execution.
|
void |
setEphemeralStorage(CfnFunction.EphemeralStorageProperty value)
The size of the function's `/tmp` directory in MB.
|
void |
setEphemeralStorage(IResolvable value)
The size of the function's `/tmp` directory in MB.
|
void |
setFileSystemConfigs(IResolvable value)
Connection settings for an Amazon EFS file system.
|
void |
setFileSystemConfigs(java.util.List<java.lang.Object> value)
Connection settings for an Amazon EFS file system.
|
void |
setFunctionName(java.lang.String value)
The name of the Lambda function, up to 64 characters in length.
|
void |
setHandler(java.lang.String value)
The name of the method within your code that Lambda calls to run your function.
|
void |
setImageConfig(CfnFunction.ImageConfigProperty value)
Configuration values that override the container image Dockerfile settings.
|
void |
setImageConfig(IResolvable value)
Configuration values that override the container image Dockerfile settings.
|
void |
setKmsKeyArn(java.lang.String value)
The ARN of the AWS Key Management Service ( AWS KMS ) customer managed key that's used to encrypt your function's [environment variables](https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-encryption) .
|
void |
setLayers(java.util.List<java.lang.String> value)
A list of [function layers](https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) to add to the function's execution environment.
|
void |
setMemorySize(java.lang.Number value)
The amount of [memory available to the function](https://docs.aws.amazon.com/lambda/latest/dg/configuration-function-common.html#configuration-memory-console) at runtime.
|
void |
setPackageType(java.lang.String value)
The type of deployment package.
|
void |
setReservedConcurrentExecutions(java.lang.Number value)
The number of simultaneous executions to reserve for the function.
|
void |
setRole(java.lang.String value)
The Amazon Resource Name (ARN) of the function's execution role.
|
void |
setRuntime(java.lang.String value)
The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) .
|
void |
setRuntimeManagementConfig(CfnFunction.RuntimeManagementConfigProperty value)
Sets the runtime management configuration for a function's version.
|
void |
setRuntimeManagementConfig(IResolvable value)
Sets the runtime management configuration for a function's version.
|
void |
setSnapStart(CfnFunction.SnapStartProperty value)
The function's [AWS Lambda SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting.
|
void |
setSnapStart(IResolvable value)
The function's [AWS Lambda SnapStart](https://docs.aws.amazon.com/lambda/latest/dg/snapstart.html) setting.
|
void |
setTimeout(java.lang.Number value)
The amount of time (in seconds) that Lambda allows a function to run before stopping it.
|
void |
setTracingConfig(CfnFunction.TracingConfigProperty value)
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) .
|
void |
setTracingConfig(IResolvable value)
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) .
|
void |
setVpcConfig(CfnFunction.VpcConfigProperty value)
For network connectivity to AWS resources in a [VPC](https://docs.aws.amazon.com/lambda/latest/dg/configuration-network.html) , specify a list of security groups and subnets in the VPC.
|
void |
setVpcConfig(IResolvable value)
For network connectivity to AWS resources in a [VPC](https://docs.aws.amazon.com/lambda/latest/dg/configuration-network.html) , specify a list of security groups and subnets in the VPC.
|
addDeletionOverride, addDependsOn, addMetadata, addOverride, addPropertyDeletionOverride, addPropertyOverride, applyRemovalPolicy, applyRemovalPolicy, applyRemovalPolicy, getAtt, getCfnOptions, getCfnResourceType, getMetadata, getUpdatedProperites, isCfnResource, shouldSynthesize, toString, validateProperties
getRef
getCreationStack, getLogicalId, getStack, isCfnElement, overrideLogicalId
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
public static final java.lang.String CFN_RESOURCE_TYPE_NAME
protected CfnFunction(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public CfnFunction(Construct scope, java.lang.String id, CfnFunctionProps props)
scope
- - scope in which this resource is defined. This parameter is required.id
- - scoped id of the resource. This parameter is required.props
- - resource properties. This parameter is required.public void inspect(TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.protected java.util.Map<java.lang.String,java.lang.Object> renderProperties(java.util.Map<java.lang.String,java.lang.Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.public java.lang.String getAttrArn()
public java.lang.String getAttrSnapStartResponseApplyOn()
public java.lang.String getAttrSnapStartResponseOptimizationStatus()
protected java.util.Map<java.lang.String,java.lang.Object> getCfnProperties()
getCfnProperties
in class CfnResource
public TagManager getTags()
public java.lang.Object getCode()
public void setCode(IResolvable value)
public void setCode(CfnFunction.CodeProperty value)
public java.lang.String getRole()
public void setRole(java.lang.String value)
public java.util.List<java.lang.String> getArchitectures()
Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64
.
public void setArchitectures(java.util.List<java.lang.String> value)
Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64
.
public java.lang.String getCodeSigningConfigArn()
A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
public void setCodeSigningConfigArn(java.lang.String value)
A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
public java.lang.Object getDeadLetterConfig()
For more information, see Dead-letter queues .
public void setDeadLetterConfig(IResolvable value)
For more information, see Dead-letter queues .
public void setDeadLetterConfig(CfnFunction.DeadLetterConfigProperty value)
For more information, see Dead-letter queues .
public java.lang.String getDescription()
public void setDescription(java.lang.String value)
public java.lang.Object getEnvironment()
public void setEnvironment(IResolvable value)
public void setEnvironment(CfnFunction.EnvironmentProperty value)
public java.lang.Object getEphemeralStorage()
The default value is 512, but it can be any whole number between 512 and 10,240 MB.
public void setEphemeralStorage(IResolvable value)
The default value is 512, but it can be any whole number between 512 and 10,240 MB.
public void setEphemeralStorage(CfnFunction.EphemeralStorageProperty value)
The default value is 512, but it can be any whole number between 512 and 10,240 MB.
public java.lang.Object getFileSystemConfigs()
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 .
public void setFileSystemConfigs(IResolvable value)
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 .
public void setFileSystemConfigs(java.util.List<java.lang.Object> value)
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 .
public java.lang.String getFunctionName()
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.
public void setFunctionName(java.lang.String value)
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.
public java.lang.String getHandler()
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 Lambda programming model .
public void setHandler(java.lang.String value)
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 Lambda programming model .
public java.lang.Object getImageConfig()
For more information, see Container image settings .
public void setImageConfig(IResolvable value)
For more information, see Container image settings .
public void setImageConfig(CfnFunction.ImageConfigProperty value)
For more information, see Container image settings .
public java.lang.String getKmsKeyArn()
public void setKmsKeyArn(java.lang.String value)
public java.util.List<java.lang.String> getLayers()
public void setLayers(java.util.List<java.lang.String> value)
public java.lang.Number getMemorySize()
public void setMemorySize(java.lang.Number value)
public java.lang.String getPackageType()
Set to Image
for container image and set Zip
for .zip file archive.
public void setPackageType(java.lang.String value)
Set to Image
for container image and set Zip
for .zip file archive.
public java.lang.Number getReservedConcurrentExecutions()
public void setReservedConcurrentExecutions(java.lang.Number value)
public java.lang.String getRuntime()
The following list includes deprecated runtimes. For more information, see Runtime deprecation policy .
public void setRuntime(java.lang.String value)
The following list includes deprecated runtimes. For more information, see Runtime deprecation policy .
public java.lang.Object getRuntimeManagementConfig()
For more information, see Runtime updates .
public void setRuntimeManagementConfig(IResolvable value)
For more information, see Runtime updates .
public void setRuntimeManagementConfig(CfnFunction.RuntimeManagementConfigProperty value)
For more information, see Runtime updates .
public java.lang.Object getSnapStart()
public void setSnapStart(IResolvable value)
public void setSnapStart(CfnFunction.SnapStartProperty value)
public java.lang.Number getTimeout()
The default is 3 seconds. The maximum allowed value is 900 seconds. For more information, see Lambda execution environment .
public void setTimeout(java.lang.Number value)
The default is 3 seconds. The maximum allowed value is 900 seconds. For more information, see Lambda execution environment .
public java.lang.Object getTracingConfig()
public void setTracingConfig(IResolvable value)
public void setTracingConfig(CfnFunction.TracingConfigProperty value)
public java.lang.Object getVpcConfig()
public void setVpcConfig(IResolvable value)
public void setVpcConfig(CfnFunction.VpcConfigProperty value)