Class NodejsFunction.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<NodejsFunction>
- Enclosing class:
- NodejsFunction
NodejsFunction
.-
Method Summary
Modifier and TypeMethodDescriptionallowAllOutbound
(Boolean allowAllOutbound) Whether to allow the Lambda to send all network traffic.allowPublicSubnet
(Boolean allowPublicSubnet) Lambda Functions in a public subnet can NOT access the internet.architecture
(Architecture architecture) The system architectures compatible with this lambda function.architectures
(List<? extends Architecture> architectures) Deprecated.awsSdkConnectionReuse
(Boolean awsSdkConnectionReuse) Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript.build()
bundling
(BundlingOptions bundling) Bundling options.codeSigningConfig
(ICodeSigningConfig codeSigningConfig) Code signing config associated with this function.static NodejsFunction.Builder
currentVersionOptions
(VersionOptions currentVersionOptions) Options for thelambda.Version
resource automatically created by thefn.currentVersion
method.deadLetterQueue
(IQueue deadLetterQueue) The SQS queue to use if DLQ is enabled.deadLetterQueueEnabled
(Boolean deadLetterQueueEnabled) Enabled DLQ.deadLetterTopic
(ITopic deadLetterTopic) The SNS topic to use as a DLQ.depsLockFilePath
(String depsLockFilePath) The path to the dependencies lock file (yarn.lock
orpackage-lock.json
).description
(String description) A description of the function.Path to the entry file (JavaScript or TypeScript).environment
(Map<String, String> environment) Key-value pairs that Lambda caches and makes available for your Lambda functions.environmentEncryption
(IKey environmentEncryption) The AWS KMS key that's used to encrypt your function's environment variables.ephemeralStorageSize
(Size ephemeralStorageSize) The size of the function’s /tmp directory in MiB.events
(List<? extends IEventSource> events) Event sources for this function.filesystem
(FileSystem filesystem) The filesystem configuration for the lambda function.functionName
(String functionName) A name for the function.The name of the exported handler in the entry file.initialPolicy
(List<? extends PolicyStatement> initialPolicy) Initial policy statements to add to the created Lambda Role.insightsVersion
(LambdaInsightsVersion insightsVersion) Specify the version of CloudWatch Lambda insights to use for monitoring.layers
(List<? extends ILayerVersion> layers) A list of layers to add to the function's execution environment.logRetention
(RetentionDays logRetention) The number of days log events are kept in CloudWatch Logs.logRetentionRetryOptions
(LogRetentionRetryOptions logRetentionRetryOptions) When log retention is specified, a custom resource attempts to create the CloudWatch log group.logRetentionRole
(IRole logRetentionRole) The IAM role for the Lambda function associated with the custom resource that sets the retention policy.maxEventAge
(Duration maxEventAge) The maximum age of a request that Lambda sends to a function for processing.memorySize
(Number memorySize) The amount of memory, in MB, that is allocated to your Lambda function.onFailure
(IDestination onFailure) The destination for failed invocations.onSuccess
(IDestination onSuccess) The destination for successful invocations.Enable profiling.profilingGroup
(IProfilingGroup profilingGroup) Profiling Group.projectRoot
(String projectRoot) The path to the directory containing project config files (package.json
ortsconfig.json
).reservedConcurrentExecutions
(Number reservedConcurrentExecutions) The maximum of concurrent executions you want to reserve for the function.retryAttempts
(Number retryAttempts) The maximum number of times to retry when the function returns an error.Lambda execution role.The runtime environment.securityGroup
(ISecurityGroup securityGroup) Deprecated.This property is deprecated, use securityGroups insteadsecurityGroups
(List<? extends ISecurityGroup> securityGroups) The list of security groups to associate with the Lambda's network interfaces.The function execution time (in seconds) after which Lambda terminates the function.Enable AWS X-Ray Tracing for Lambda Function.VPC network to place Lambda network interfaces.vpcSubnets
(SubnetSelection vpcSubnets) Where to place the network interfaces within the VPC.
-
Method Details
-
create
- Parameters:
scope
- This parameter is required.id
- This parameter is required.- Returns:
- a new instance of
NodejsFunction.Builder
.
-
maxEventAge
The maximum age of a request that Lambda sends to a function for processing.Minimum: 60 seconds Maximum: 6 hours
Default: Duration.hours(6)
- Parameters:
maxEventAge
- The maximum age of a request that Lambda sends to a function for processing. This parameter is required.- Returns:
this
-
onFailure
The destination for failed invocations.Default: - no destination
- Parameters:
onFailure
- The destination for failed invocations. This parameter is required.- Returns:
this
-
onSuccess
The destination for successful invocations.Default: - no destination
- Parameters:
onSuccess
- The destination for successful invocations. This parameter is required.- Returns:
this
-
retryAttempts
The maximum number of times to retry when the function returns an error.Minimum: 0 Maximum: 2
Default: 2
- Parameters:
retryAttempts
- The maximum number of times to retry when the function returns an error. This parameter is required.- Returns:
this
-
allowAllOutbound
Whether to allow the Lambda to send all network traffic.If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets.
Default: true
- Parameters:
allowAllOutbound
- Whether to allow the Lambda to send all network traffic. This parameter is required.- Returns:
this
-
allowPublicSubnet
Lambda Functions in a public subnet can NOT access the internet.Use this property to acknowledge this limitation and still place the function in a public subnet.
Default: false
- Parameters:
allowPublicSubnet
- Lambda Functions in a public subnet can NOT access the internet. This parameter is required.- Returns:
this
- See Also:
-
architecture
The system architectures compatible with this lambda function.Default: Architecture.X86_64
- Parameters:
architecture
- The system architectures compatible with this lambda function. This parameter is required.- Returns:
this
-
architectures
@Stability(Deprecated) @Deprecated public NodejsFunction.Builder architectures(List<? extends Architecture> architectures) Deprecated.usearchitecture
(deprecated) DEPRECATED.Default: [Architecture.X86_64]
- Parameters:
architectures
- DEPRECATED. This parameter is required.- Returns:
this
-
codeSigningConfig
@Stability(Stable) public NodejsFunction.Builder codeSigningConfig(ICodeSigningConfig codeSigningConfig) Code signing config associated with this function.Default: - Not Sign the Code
- Parameters:
codeSigningConfig
- Code signing config associated with this function. This parameter is required.- Returns:
this
-
currentVersionOptions
@Stability(Stable) public NodejsFunction.Builder currentVersionOptions(VersionOptions currentVersionOptions) Options for thelambda.Version
resource automatically created by thefn.currentVersion
method.Default: - default options as described in `VersionOptions`
- Parameters:
currentVersionOptions
- Options for thelambda.Version
resource automatically created by thefn.currentVersion
method. This parameter is required.- Returns:
this
-
deadLetterQueue
The SQS queue to use if DLQ is enabled.If SNS topic is desired, specify
deadLetterTopic
property instead.Default: - SQS queue with 14 day retention period if `deadLetterQueueEnabled` is `true`
- Parameters:
deadLetterQueue
- The SQS queue to use if DLQ is enabled. This parameter is required.- Returns:
this
-
deadLetterQueueEnabled
@Stability(Stable) public NodejsFunction.Builder deadLetterQueueEnabled(Boolean deadLetterQueueEnabled) Enabled DLQ.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.
- Parameters:
deadLetterQueueEnabled
- Enabled DLQ. This parameter is required.- Returns:
this
-
deadLetterTopic
The SNS topic to use as a DLQ.Note that if
deadLetterQueueEnabled
is set totrue
, an SQS queue will be created rather than an SNS topic. Using an SNS topic as a DLQ requires this property to be set explicitly.Default: - no SNS topic
- Parameters:
deadLetterTopic
- The SNS topic to use as a DLQ. This parameter is required.- Returns:
this
-
description
A description of the function.Default: - No description.
- Parameters:
description
- A description of the function. This parameter is required.- Returns:
this
-
environment
Key-value pairs that Lambda caches and makes available for your Lambda functions.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.
- Parameters:
environment
- Key-value pairs that Lambda caches and makes available for your Lambda functions. This parameter is required.- Returns:
this
-
environmentEncryption
The AWS KMS key that's used to encrypt your function's environment variables.Default: - AWS Lambda creates and uses an AWS managed customer master key (CMK).
- Parameters:
environmentEncryption
- The AWS KMS key that's used to encrypt your function's environment variables. This parameter is required.- Returns:
this
-
ephemeralStorageSize
The size of the function’s /tmp directory in MiB.Default: 512 MiB
- Parameters:
ephemeralStorageSize
- The size of the function’s /tmp directory in MiB. This parameter is required.- Returns:
this
-
events
Event sources for this function.You can also add event sources using
addEventSource
.Default: - No event sources.
- Parameters:
events
- Event sources for this function. This parameter is required.- Returns:
this
-
filesystem
The filesystem configuration for the lambda function.Default: - will not mount any filesystem
- Parameters:
filesystem
- The filesystem configuration for the lambda function. This parameter is required.- Returns:
this
-
functionName
A name for the function.Default: - AWS CloudFormation generates a unique physical ID and uses that ID for the function's name. For more information, see Name Type.
- Parameters:
functionName
- A name for the function. This parameter is required.- Returns:
this
-
initialPolicy
@Stability(Stable) public NodejsFunction.Builder initialPolicy(List<? extends PolicyStatement> initialPolicy) Initial policy statements to add to the created Lambda Role.You can call
addToRolePolicy
to the created lambda to add statements post creation.Default: - No policy statements are added to the created Lambda role.
- Parameters:
initialPolicy
- Initial policy statements to add to the created Lambda Role. This parameter is required.- Returns:
this
-
insightsVersion
@Stability(Stable) public NodejsFunction.Builder insightsVersion(LambdaInsightsVersion insightsVersion) Specify the version of CloudWatch Lambda insights to use for monitoring.Default: - No Lambda Insights
- Parameters:
insightsVersion
- Specify the version of CloudWatch Lambda insights to use for monitoring. This parameter is required.- Returns:
this
- See Also:
-
layers
A list of layers to add to the function's execution environment.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 multiple functions.
Default: - No layers.
- Parameters:
layers
- A list of layers to add to the function's execution environment. This parameter is required.- Returns:
this
-
logRetention
The number of days log events are kept in CloudWatch Logs.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
- Parameters:
logRetention
- The number of days log events are kept in CloudWatch Logs. This parameter is required.- Returns:
this
-
logRetentionRetryOptions
@Stability(Stable) public NodejsFunction.Builder logRetentionRetryOptions(LogRetentionRetryOptions logRetentionRetryOptions) When log retention is specified, a custom resource attempts to create the CloudWatch log group.These options control the retry policy when interacting with CloudWatch APIs.
Default: - Default AWS SDK retry options.
- Parameters:
logRetentionRetryOptions
- When log retention is specified, a custom resource attempts to create the CloudWatch log group. This parameter is required.- Returns:
this
-
logRetentionRole
The IAM role for the Lambda function associated with the custom resource that sets the retention policy.Default: - A new role is created.
- Parameters:
logRetentionRole
- The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This parameter is required.- Returns:
this
-
memorySize
The amount of memory, in MB, that is allocated to your Lambda function.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
- Parameters:
memorySize
- The amount of memory, in MB, that is allocated to your Lambda function. This parameter is required.- Returns:
this
-
profiling
Enable profiling.Default: - No profiling.
- Parameters:
profiling
- Enable profiling. This parameter is required.- Returns:
this
- See Also:
-
profilingGroup
Profiling Group.Default: - A new profiling group will be created if `profiling` is set.
- Parameters:
profilingGroup
- Profiling Group. This parameter is required.- Returns:
this
- See Also:
-
reservedConcurrentExecutions
@Stability(Stable) public NodejsFunction.Builder reservedConcurrentExecutions(Number reservedConcurrentExecutions) The maximum of concurrent executions you want to reserve for the function.Default: - No specific limit - account limit.
- Parameters:
reservedConcurrentExecutions
- The maximum of concurrent executions you want to reserve for the function. This parameter is required.- Returns:
this
- See Also:
-
role
Lambda execution 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`.
- Parameters:
role
- Lambda execution role. This parameter is required.- Returns:
this
-
securityGroup
@Stability(Deprecated) @Deprecated public NodejsFunction.Builder securityGroup(ISecurityGroup securityGroup) Deprecated.- This property is deprecated, use securityGroups instead
(deprecated) What security group to associate with the Lambda's network interfaces. This property is being deprecated, consider using securityGroups instead.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.
- Parameters:
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.- Returns:
this
-
securityGroups
@Stability(Stable) public NodejsFunction.Builder securityGroups(List<? extends ISecurityGroup> securityGroups) The list of security groups to associate with the Lambda's network interfaces.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.
- Parameters:
securityGroups
- The list of security groups to associate with the Lambda's network interfaces. This parameter is required.- Returns:
this
-
timeout
The function execution time (in seconds) after which Lambda terminates the function.Because the execution time affects cost, set this value based on the function's expected execution time.
Default: Duration.seconds(3)
- Parameters:
timeout
- The function execution time (in seconds) after which Lambda terminates the function. This parameter is required.- Returns:
this
-
tracing
Enable AWS X-Ray Tracing for Lambda Function.Default: Tracing.Disabled
- Parameters:
tracing
- Enable AWS X-Ray Tracing for Lambda Function. This parameter is required.- Returns:
this
-
vpc
VPC network to place Lambda network interfaces.Specify this if the Lambda function needs to access resources in a VPC.
Default: - Function is not placed within a VPC.
- Parameters:
vpc
- VPC network to place Lambda network interfaces. This parameter is required.- Returns:
this
-
vpcSubnets
Where to place the network interfaces within the VPC.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
- Parameters:
vpcSubnets
- Where to place the network interfaces within the VPC. This parameter is required.- Returns:
this
-
awsSdkConnectionReuse
@Stability(Stable) public NodejsFunction.Builder awsSdkConnectionReuse(Boolean awsSdkConnectionReuse) Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript.This sets the
AWS_NODEJS_CONNECTION_REUSE_ENABLED
environment variable to1
.Default: true
- Parameters:
awsSdkConnectionReuse
- Whether to automatically reuse TCP connections when working with the AWS SDK for JavaScript. This parameter is required.- Returns:
this
- See Also:
-
bundling
Bundling options.Default: - use default bundling options: no minify, no sourcemap, all modules are bundled.
- Parameters:
bundling
- Bundling options. This parameter is required.- Returns:
this
-
depsLockFilePath
The path to the dependencies lock file (yarn.lock
orpackage-lock.json
).This will be used as the source for the volume mounted in the Docker container.
Modules specified in
nodeModules
will be installed using the right installer (npm
oryarn
) along with this lock file.Default: - the path is found by walking up parent directories searching for a `yarn.lock` or `package-lock.json` file
- Parameters:
depsLockFilePath
- The path to the dependencies lock file (yarn.lock
orpackage-lock.json
). This parameter is required.- Returns:
this
-
entry
Path to the entry file (JavaScript or TypeScript).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`.
- Parameters:
entry
- Path to the entry file (JavaScript or TypeScript). This parameter is required.- Returns:
this
-
handler
The name of the exported handler in the entry file.Default: handler
- Parameters:
handler
- The name of the exported handler in the entry file. This parameter is required.- Returns:
this
-
projectRoot
The path to the directory containing project config files (package.json
ortsconfig.json
).Default: - the directory containing the `depsLockFilePath`
- Parameters:
projectRoot
- The path to the directory containing project config files (package.json
ortsconfig.json
). This parameter is required.- Returns:
this
-
runtime
The runtime environment.Only runtimes of the Node.js family are supported.
Default: Runtime.NODEJS_14_X
- Parameters:
runtime
- The runtime environment. This parameter is required.- Returns:
this
-
build
- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<NodejsFunction>
- Returns:
- a newly built instance of
NodejsFunction
.
-
architecture