@Stability(value=Experimental) public static final class NodejsFunction.Builder extends Object implements software.amazon.jsii.Builder<NodejsFunction>
NodejsFunction.| Modifier and Type | Method and Description |
|---|---|
NodejsFunction.Builder |
allowAllOutbound(Boolean allowAllOutbound)
Whether to allow the Lambda to send all network traffic.
|
NodejsFunction.Builder |
allowPublicSubnet(Boolean allowPublicSubnet)
Lambda Functions in a public subnet can NOT access the internet.
|
NodejsFunction.Builder |
awsSdkConnectionReuse(Boolean awsSdkConnectionReuse)
(experimental) Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript.
|
NodejsFunction |
build() |
NodejsFunction.Builder |
buildArgs(Map<String,String> buildArgs)
(experimental) Build arguments to pass when building the bundling image.
|
NodejsFunction.Builder |
bundlingDockerImage(BundlingDockerImage bundlingDockerImage)
(experimental) A custom bundling Docker image.
|
NodejsFunction.Builder |
cacheDir(String cacheDir)
(experimental) The cache directory (relative to the project root).
|
static NodejsFunction.Builder |
create(Construct scope,
String id) |
NodejsFunction.Builder |
currentVersionOptions(VersionOptions currentVersionOptions)
Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method.
|
NodejsFunction.Builder |
deadLetterQueue(software.amazon.awscdk.services.sqs.IQueue deadLetterQueue)
The SQS queue to use if DLQ is enabled.
|
NodejsFunction.Builder |
deadLetterQueueEnabled(Boolean deadLetterQueueEnabled)
Enabled DLQ.
|
NodejsFunction.Builder |
description(String description)
A description of the function.
|
NodejsFunction.Builder |
entry(String entry)
(experimental) Path to the entry file (JavaScript or TypeScript).
|
NodejsFunction.Builder |
environment(Map<String,String> environment)
Key-value pairs that Lambda caches and makes available for your Lambda functions.
|
NodejsFunction.Builder |
events(List<? extends IEventSource> events)
Event sources for this function.
|
NodejsFunction.Builder |
externalModules(List<String> externalModules)
(experimental) A list of modules that should be considered as externals (already available in the runtime).
|
NodejsFunction.Builder |
filesystem(FileSystem filesystem)
The filesystem configuration for the lambda function.
|
NodejsFunction.Builder |
forceDockerBundling(Boolean forceDockerBundling)
(experimental) Force bundling in a Docker container even if local bundling is possible.This is useful if your function relies on node modules that should be installed (`nodeModules`) in a Lambda compatible environment.
|
NodejsFunction.Builder |
functionName(String functionName)
A name for the function.
|
NodejsFunction.Builder |
handler(String handler)
(experimental) The name of the exported handler in the entry file.
|
NodejsFunction.Builder |
initialPolicy(List<? extends software.amazon.awscdk.services.iam.PolicyStatement> initialPolicy)
Initial policy statements to add to the created Lambda Role.
|
NodejsFunction.Builder |
layers(List<? extends ILayerVersion> layers)
A list of layers to add to the function's execution environment.
|
NodejsFunction.Builder |
logRetention(software.amazon.awscdk.services.logs.RetentionDays logRetention)
The number of days log events are kept in CloudWatch Logs.
|
NodejsFunction.Builder |
logRetentionRetryOptions(LogRetentionRetryOptions logRetentionRetryOptions)
When log retention is specified, a custom resource attempts to create the CloudWatch log group.
|
NodejsFunction.Builder |
logRetentionRole(software.amazon.awscdk.services.iam.IRole logRetentionRole)
The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
|
NodejsFunction.Builder |
maxEventAge(Duration maxEventAge)
The maximum age of a request that Lambda sends to a function for processing.
|
NodejsFunction.Builder |
memorySize(Number memorySize)
The amount of memory, in MB, that is allocated to your Lambda function.
|
NodejsFunction.Builder |
minify(Boolean minify)
(experimental) Whether to minify files when bundling.
|
NodejsFunction.Builder |
nodeModules(List<String> nodeModules)
(experimental) A list of modules that should be installed instead of bundled.
|
NodejsFunction.Builder |
onFailure(IDestination onFailure)
The destination for failed invocations.
|
NodejsFunction.Builder |
onSuccess(IDestination onSuccess)
The destination for successful invocations.
|
NodejsFunction.Builder |
parcelEnvironment(Map<String,String> parcelEnvironment)
(experimental) Environment variables defined when Parcel runs.
|
NodejsFunction.Builder |
parcelVersion(String parcelVersion)
(experimental) The version of Parcel to use when running in a Docker container.
|
NodejsFunction.Builder |
profiling(Boolean profiling)
Enable profiling.
|
NodejsFunction.Builder |
profilingGroup(software.amazon.awscdk.services.codeguruprofiler.IProfilingGroup profilingGroup)
Profiling Group.
|
NodejsFunction.Builder |
projectRoot(String projectRoot)
(experimental) The root of the project.
|
NodejsFunction.Builder |
reservedConcurrentExecutions(Number reservedConcurrentExecutions)
The maximum of concurrent executions you want to reserve for the function.
|
NodejsFunction.Builder |
retryAttempts(Number retryAttempts)
The maximum number of times to retry when the function returns an error.
|
NodejsFunction.Builder |
role(software.amazon.awscdk.services.iam.IRole role)
Lambda execution role.
|
NodejsFunction.Builder |
runtime(Runtime runtime)
(experimental) The runtime environment.
|
NodejsFunction.Builder |
securityGroup(software.amazon.awscdk.services.ec2.ISecurityGroup securityGroup)
Deprecated.
- This property is deprecated, use securityGroups instead
|
NodejsFunction.Builder |
securityGroups(List<? extends software.amazon.awscdk.services.ec2.ISecurityGroup> securityGroups)
The list of security groups to associate with the Lambda's network interfaces.
|
NodejsFunction.Builder |
sourceMaps(Boolean sourceMaps)
(experimental) Whether to include source maps when bundling.
|
NodejsFunction.Builder |
timeout(Duration timeout)
The function execution time (in seconds) after which Lambda terminates the function.
|
NodejsFunction.Builder |
tracing(Tracing tracing)
Enable AWS X-Ray Tracing for Lambda Function.
|
NodejsFunction.Builder |
vpc(software.amazon.awscdk.services.ec2.IVpc vpc)
VPC network to place Lambda network interfaces.
|
NodejsFunction.Builder |
vpcSubnets(software.amazon.awscdk.services.ec2.SubnetSelection vpcSubnets)
Where to place the network interfaces within the VPC.
|
@Stability(value=Experimental) public static NodejsFunction.Builder create(Construct scope, String id)
scope - This parameter is required.id - This parameter is required.NodejsFunction.Builder.@Stability(value=Stable) public NodejsFunction.Builder maxEventAge(Duration maxEventAge)
Minimum: 60 seconds Maximum: 6 hours
Default: Duration.hours(6)
maxEventAge - The maximum age of a request that Lambda sends to a function for processing. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder onFailure(IDestination onFailure)
Default: - no destination
onFailure - The destination for failed invocations. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder onSuccess(IDestination onSuccess)
Default: - no destination
onSuccess - The destination for successful invocations. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder retryAttempts(Number retryAttempts)
Minimum: 0 Maximum: 2
Default: 2
retryAttempts - The maximum number of times to retry when the function returns an error. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder allowAllOutbound(Boolean allowAllOutbound)
If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets.
Default: true
allowAllOutbound - Whether to allow the Lambda to send all network traffic. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder allowPublicSubnet(Boolean allowPublicSubnet)
Use this property to acknowledge this limitation and still place the function in a public subnet.
Default: false
allowPublicSubnet - Lambda Functions in a public subnet can NOT access the internet. This parameter is required.thishttps://stackoverflow.com/questions/52992085/why-cant-an-aws-lambda-function-inside-a-public-subnet-in-a-vpc-connect-to-the/52994841#52994841@Stability(value=Stable) public NodejsFunction.Builder currentVersionOptions(VersionOptions currentVersionOptions)
Default: - default options as described in `VersionOptions`
currentVersionOptions - Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder deadLetterQueue(software.amazon.awscdk.services.sqs.IQueue deadLetterQueue)
Default: - SQS queue with 14 day retention period if `deadLetterQueueEnabled` is `true`
deadLetterQueue - The SQS queue to use if DLQ is enabled. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder deadLetterQueueEnabled(Boolean deadLetterQueueEnabled)
If deadLetterQueue is undefined,
an SQS queue with default options will be defined for your Function.
Default: - false unless `deadLetterQueue` is set, which implies DLQ is enabled.
deadLetterQueueEnabled - Enabled DLQ. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder description(String description)
Default: - No description.
description - A description of the function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder environment(Map<String,String> environment)
Use environment variables to apply configuration changes, such as test and production environment configurations, without changing your Lambda function source code.
Default: - No environment variables.
environment - Key-value pairs that Lambda caches and makes available for your Lambda functions. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder events(List<? extends IEventSource> events)
You can also add event sources using addEventSource.
Default: - No event sources.
events - Event sources for this function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder filesystem(FileSystem filesystem)
Default: - will not mount any filesystem
filesystem - The filesystem configuration for the lambda function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder functionName(String functionName)
Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the function's name. For more information, see Name Type.
functionName - A name for the function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder initialPolicy(List<? extends software.amazon.awscdk.services.iam.PolicyStatement> initialPolicy)
You can call addToRolePolicy to the created lambda to add statements post creation.
Default: - No policy statements are added to the created Lambda role.
initialPolicy - Initial policy statements to add to the created Lambda Role. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder layers(List<? extends ILayerVersion> layers)
You can configure your Lambda function to pull in additional code during initialization in the form of layers. Layers are packages of libraries or other dependencies that can be used by mulitple functions.
Default: - No layers.
layers - A list of layers to add to the function's execution environment. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder logRetention(software.amazon.awscdk.services.logs.RetentionDays logRetention)
When updating
this property, unsetting it doesn't remove the log retention policy. To
remove the retention policy, set the value to INFINITE.
Default: logs.RetentionDays.INFINITE
logRetention - The number of days log events are kept in CloudWatch Logs. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder logRetentionRetryOptions(LogRetentionRetryOptions logRetentionRetryOptions)
These options control the retry policy when interacting with CloudWatch APIs.
Default: - Default AWS SDK retry options.
logRetentionRetryOptions - When log retention is specified, a custom resource attempts to create the CloudWatch log group. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder logRetentionRole(software.amazon.awscdk.services.iam.IRole logRetentionRole)
Default: - A new role is created.
logRetentionRole - The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder memorySize(Number memorySize)
Lambda uses this value to proportionally allocate the amount of CPU power. For more information, see Resource Model in the AWS Lambda Developer Guide.
Default: 128
memorySize - The amount of memory, in MB, that is allocated to your Lambda function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder profiling(Boolean profiling)
Default: - No profiling.
profiling - Enable profiling. This parameter is required.thishttps://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html@Stability(value=Stable) public NodejsFunction.Builder profilingGroup(software.amazon.awscdk.services.codeguruprofiler.IProfilingGroup profilingGroup)
Default: - A new profiling group will be created if `profiling` is set.
profilingGroup - Profiling Group. This parameter is required.thishttps://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html@Stability(value=Stable) public NodejsFunction.Builder reservedConcurrentExecutions(Number reservedConcurrentExecutions)
Default: - No specific limit - account limit.
reservedConcurrentExecutions - The maximum of concurrent executions you want to reserve for the function. This parameter is required.thishttps://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html@Stability(value=Stable) public NodejsFunction.Builder role(software.amazon.awscdk.services.iam.IRole role)
This is the role that will be assumed by the function upon execution. It controls the permissions that the function will have. The Role must be assumable by the 'lambda.amazonaws.com' service principal.
The default Role automatically has permissions granted for Lambda execution. If you provide a Role, you must add the relevant AWS managed policies yourself.
The relevant managed policies are "service-role/AWSLambdaBasicExecutionRole" and "service-role/AWSLambdaVPCAccessExecutionRole".
Default: - A unique role will be generated for this lambda function. Both supplied and generated roles can always be changed by calling `addToRolePolicy`.
role - Lambda execution role. This parameter is required.this@Stability(value=Deprecated) @Deprecated public NodejsFunction.Builder securityGroup(software.amazon.awscdk.services.ec2.ISecurityGroup securityGroup)
Only used if 'vpc' is supplied.
Use securityGroups property instead. Function constructor will throw an error if both are specified.
Default: - If the function is placed within a VPC and a security group is not specified, either by this or securityGroups prop, a dedicated security group will be created for this function.
securityGroup - What security group to associate with the Lambda's network interfaces. This property is being deprecated, consider using securityGroups instead. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder securityGroups(List<? extends software.amazon.awscdk.services.ec2.ISecurityGroup> securityGroups)
Only used if 'vpc' is supplied.
Default: - If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function.
securityGroups - The list of security groups to associate with the Lambda's network interfaces. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder timeout(Duration timeout)
Because the execution time affects cost, set this value based on the function's expected execution time.
Default: Duration.seconds(3)
timeout - The function execution time (in seconds) after which Lambda terminates the function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder tracing(Tracing tracing)
Default: Tracing.Disabled
tracing - Enable AWS X-Ray Tracing for Lambda Function. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder vpc(software.amazon.awscdk.services.ec2.IVpc vpc)
Specify this if the Lambda function needs to access resources in a VPC.
Default: - Function is not placed within a VPC.
vpc - VPC network to place Lambda network interfaces. This parameter is required.this@Stability(value=Stable) public NodejsFunction.Builder vpcSubnets(software.amazon.awscdk.services.ec2.SubnetSelection vpcSubnets)
Only used if 'vpc' is supplied. Note: internet access for Lambdas requires a NAT gateway, so picking Public subnets is not allowed.
Default: - the Vpc default strategy if not specified
vpcSubnets - Where to place the network interfaces within the VPC. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder buildArgs(Map<String,String> buildArgs)
Default: - no build arguments are passed
buildArgs - Build arguments to pass when building the bundling image. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder bundlingDockerImage(BundlingDockerImage bundlingDockerImage)
This image should have Parcel installed at /. If you plan to use nodeModules
it should also have npm or yarn depending on the lock file you're using.
See https://github.com/aws/aws-cdk/blob/master/packages/%40aws-cdk/aws-lambda-nodejs/parcel/Dockerfile for the default image provided by @aws-cdk/aws-lambda-nodejs.
Default: - use the Docker image provided by
bundlingDockerImage - A custom bundling Docker image. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder cacheDir(String cacheDir)
Parcel uses a filesystem cache for fast rebuilds.
Default: - `.parcel-cache` in the working directory
cacheDir - The cache directory (relative to the project root). This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder externalModules(List<String> externalModules)
Default: ['aws-sdk']
externalModules - A list of modules that should be considered as externals (already available in the runtime). This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder forceDockerBundling(Boolean forceDockerBundling)
Default: false
forceDockerBundling - Force bundling in a Docker container even if local bundling is possible.This is useful if your function relies on node modules that should be installed (`nodeModules`) in a Lambda compatible environment. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder minify(Boolean minify)
Default: false
minify - Whether to minify files when bundling. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder nodeModules(List<String> nodeModules)
Modules are installed in a Lambda compatible environnment.
Default: - all modules are bundled
nodeModules - A list of modules that should be installed instead of bundled. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder parcelEnvironment(Map<String,String> parcelEnvironment)
Default: - no environment variables are defined.
parcelEnvironment - Environment variables defined when Parcel runs. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder parcelVersion(String parcelVersion)
Default: - 2.0.0-beta.1
parcelVersion - The version of Parcel to use when running in a Docker container. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder projectRoot(String projectRoot)
This will be used as the source for the volume
mounted in the Docker container. If you specify this prop, ensure that
this path includes entry and any module/dependencies used by your
function otherwise bundling will not be possible.
Default: - the closest path containing a .git folder
projectRoot - The root of the project. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder sourceMaps(Boolean sourceMaps)
Default: false
sourceMaps - Whether to include source maps when bundling. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder awsSdkConnectionReuse(Boolean awsSdkConnectionReuse)
This sets the AWS_NODEJS_CONNECTION_REUSE_ENABLED environment variable
to 1.
Default: true
awsSdkConnectionReuse - Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript. This parameter is required.thishttps://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/node-reusing-connections.html@Stability(value=Experimental) public NodejsFunction.Builder entry(String entry)
Default: - Derived from the name of the defining file and the construct's id. If the `NodejsFunction` is defined in `stack.ts` with `my-handler` as id (`new NodejsFunction(this, 'my-handler')`), the construct will look at `stack.my-handler.ts` and `stack.my-handler.js`.
entry - Path to the entry file (JavaScript or TypeScript). This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder handler(String handler)
Default: handler
handler - The name of the exported handler in the entry file. This parameter is required.this@Stability(value=Experimental) public NodejsFunction.Builder runtime(Runtime runtime)
Only runtimes of the Node.js family are supported.
Default: - `NODEJS_12_X` if `process.versions.node` >= '12.0.0', `NODEJS_10_X` otherwise.
runtime - The runtime environment. This parameter is required.this@Stability(value=Experimental) public NodejsFunction build()
build in interface software.amazon.jsii.Builder<NodejsFunction>Copyright © 2020. All rights reserved.