@Generated(value="jsii-pacmak/1.57.0 (build f614666)", date="2022-04-22T09:30:48.947Z") @Stability(value=Stable) 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") .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.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.
|
software.amazon.jsii.JsiiObject.InitializationMode
IInspectable.Jsii$Default, IInspectable.Jsii$Proxy
Modifier and Type | Field and Description |
---|---|
static String |
CFN_RESOURCE_TYPE_NAME
The CloudFormation resource type name for this resource class.
|
Modifier | Constructor and Description |
---|---|
|
CfnFunction(software.constructs.Construct scope,
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 |
---|---|
List<String> |
getArchitectures()
The instruction set architecture that the function supports.
|
String |
getAttrArn()
The Amazon Resource Name (ARN) of the function.
|
protected Map<String,Object> |
getCfnProperties() |
Object |
getCode()
The code for the function.
|
String |
getCodeSigningConfigArn()
To enable code signing for this function, specify the ARN of a code-signing configuration.
|
Object |
getDeadLetterConfig()
A dead letter queue configuration that specifies the queue or topic where Lambda sends asynchronous events when they fail processing.
|
String |
getDescription()
A description of the function.
|
Object |
getEnvironment()
Environment variables that are accessible from function code during execution.
|
Object |
getEphemeralStorage()
The size of the function’s /tmp directory in MB.
|
Object |
getFileSystemConfigs()
Connection settings for an Amazon EFS file system.
|
String |
getFunctionName()
The name of the Lambda function, up to 64 characters in length.
|
String |
getHandler()
The name of the method within your code that Lambda calls to execute your function.
|
Object |
getImageConfig()
Configuration values that override the container image Dockerfile settings.
|
String |
getKmsKeyArn()
The ARN of the AWS Key Management Service ( AWS KMS ) key that's used to encrypt your function's environment variables.
|
List<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.
|
Number |
getMemorySize()
The amount of [memory available to the function](https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html) at runtime.
|
String |
getPackageType()
The type of deployment package.
|
Number |
getReservedConcurrentExecutions()
The number of simultaneous executions to reserve for the function.
|
String |
getRole()
The Amazon Resource Name (ARN) of the function's execution role.
|
String |
getRuntime()
The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) .
|
TagManager |
getTags()
A list of [tags](https://docs.aws.amazon.com/lambda/latest/dg/tagging.html) to apply to the function.
|
Number |
getTimeout()
The amount of time (in seconds) that Lambda allows a function to run before stopping it.
|
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) .
|
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 Map<String,Object> |
renderProperties(Map<String,Object> props) |
void |
setArchitectures(List<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(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(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(List<Object> value)
Connection settings for an Amazon EFS file system.
|
void |
setFunctionName(String value)
The name of the Lambda function, up to 64 characters in length.
|
void |
setHandler(String value)
The name of the method within your code that Lambda calls to execute 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(String value)
The ARN of the AWS Key Management Service ( AWS KMS ) key that's used to encrypt your function's environment variables.
|
void |
setLayers(List<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(Number value)
The amount of [memory available to the function](https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html) at runtime.
|
void |
setPackageType(String value)
The type of deployment package.
|
void |
setReservedConcurrentExecutions(Number value)
The number of simultaneous executions to reserve for the function.
|
void |
setRole(String value)
The Amazon Resource Name (ARN) of the function's execution role.
|
void |
setRuntime(String value)
The identifier of the function's [runtime](https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html) .
|
void |
setTimeout(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
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
@Stability(value=Stable) public static final String CFN_RESOURCE_TYPE_NAME
protected CfnFunction(software.amazon.jsii.JsiiObjectRef objRef)
protected CfnFunction(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) public CfnFunction(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull 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.@Stability(value=Stable) public void inspect(@NotNull TreeInspector inspector)
inspect
in interface IInspectable
inspector
- - tree inspector to collect and process attributes. This parameter is required.@Stability(value=Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
renderProperties
in class CfnResource
props
- This parameter is required.@Stability(value=Stable) @NotNull public String getAttrArn()
@Stability(value=Stable) @NotNull protected Map<String,Object> getCfnProperties()
getCfnProperties
in class CfnResource
@Stability(value=Stable) @NotNull public TagManager getTags()
@Stability(value=Stable) @NotNull public Object getCode()
@Stability(value=Stable) public void setCode(@NotNull CfnFunction.CodeProperty value)
@Stability(value=Stable) public void setCode(@NotNull IResolvable value)
@Stability(value=Stable) @NotNull public String getRole()
@Stability(value=Stable) public void setRole(@NotNull String value)
@Stability(value=Stable) @Nullable public List<String> getArchitectures()
Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64
.
@Stability(value=Stable) public void setArchitectures(@Nullable List<String> value)
Enter a string array with one of the valid values (arm64 or x86_64). The default value is x86_64
.
@Stability(value=Stable) @Nullable public String getCodeSigningConfigArn()
A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
@Stability(value=Stable) public void setCodeSigningConfigArn(@Nullable String value)
A code-signing configuration includes a set of signing profiles, which define the trusted publishers for this function.
@Stability(value=Stable) @Nullable public Object getDeadLetterConfig()
For more information, see Dead Letter Queues .
@Stability(value=Stable) public void setDeadLetterConfig(@Nullable CfnFunction.DeadLetterConfigProperty value)
For more information, see Dead Letter Queues .
@Stability(value=Stable) public void setDeadLetterConfig(@Nullable IResolvable value)
For more information, see Dead Letter Queues .
@Stability(value=Stable) @Nullable public String getDescription()
@Stability(value=Stable) public void setDescription(@Nullable String value)
@Stability(value=Stable) @Nullable public Object getEnvironment()
@Stability(value=Stable) public void setEnvironment(@Nullable CfnFunction.EnvironmentProperty value)
@Stability(value=Stable) public void setEnvironment(@Nullable IResolvable value)
@Stability(value=Stable) @Nullable public Object getEphemeralStorage()
The default value is 512, but can be any whole number between 512 and 10240 MB.
@Stability(value=Stable) public void setEphemeralStorage(@Nullable CfnFunction.EphemeralStorageProperty value)
The default value is 512, but can be any whole number between 512 and 10240 MB.
@Stability(value=Stable) public void setEphemeralStorage(@Nullable IResolvable value)
The default value is 512, but can be any whole number between 512 and 10240 MB.
@Stability(value=Stable) @Nullable public 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 .
@Stability(value=Stable) public void setFileSystemConfigs(@Nullable 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 .
@Stability(value=Stable) public void setFileSystemConfigs(@Nullable List<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 .
@Stability(value=Stable) @Nullable public 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.
@Stability(value=Stable) public void setFunctionName(@Nullable 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.
@Stability(value=Stable) @Nullable public 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 Programming Model .
@Stability(value=Stable) public void setHandler(@Nullable 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 Programming Model .
@Stability(value=Stable) @Nullable public Object getImageConfig()
See Container settings .
@Stability(value=Stable) public void setImageConfig(@Nullable CfnFunction.ImageConfigProperty value)
See Container settings .
@Stability(value=Stable) public void setImageConfig(@Nullable IResolvable value)
See Container settings .
@Stability(value=Stable) @Nullable public String getKmsKeyArn()
If it's not provided, AWS Lambda uses a default service key.
@Stability(value=Stable) public void setKmsKeyArn(@Nullable String value)
If it's not provided, AWS Lambda uses a default service key.
@Stability(value=Stable) @Nullable public List<String> getLayers()
@Stability(value=Stable) public void setLayers(@Nullable List<String> value)
@Stability(value=Stable) @Nullable public Number getMemorySize()
@Stability(value=Stable) public void setMemorySize(@Nullable Number value)
@Stability(value=Stable) @Nullable public String getPackageType()
Set to Image
for container image and set Zip
for .zip file archive.
@Stability(value=Stable) public void setPackageType(@Nullable String value)
Set to Image
for container image and set Zip
for .zip file archive.
@Stability(value=Stable) @Nullable public Number getReservedConcurrentExecutions()
@Stability(value=Stable) public void setReservedConcurrentExecutions(@Nullable Number value)
@Stability(value=Stable) @Nullable public String getRuntime()
@Stability(value=Stable) public void setRuntime(@Nullable String value)
@Stability(value=Stable) @Nullable public Number getTimeout()
The default is 3 seconds. The maximum allowed value is 900 seconds. For additional information, see Lambda execution environment .
@Stability(value=Stable) public void setTimeout(@Nullable Number value)
The default is 3 seconds. The maximum allowed value is 900 seconds. For additional information, see Lambda execution environment .
@Stability(value=Stable) @Nullable public Object getTracingConfig()
@Stability(value=Stable) public void setTracingConfig(@Nullable CfnFunction.TracingConfigProperty value)
@Stability(value=Stable) public void setTracingConfig(@Nullable IResolvable value)
@Stability(value=Stable) @Nullable public Object getVpcConfig()
@Stability(value=Stable) public void setVpcConfig(@Nullable CfnFunction.VpcConfigProperty value)
@Stability(value=Stable) public void setVpcConfig(@Nullable IResolvable value)
Copyright © 2022. All rights reserved.