Class FunctionOptions.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<FunctionOptions>
- Enclosing interface:
- FunctionOptions
FunctionOptions
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadotInstrumentation
(AdotInstrumentationConfig adotInstrumentation) Sets the value ofFunctionOptions.getAdotInstrumentation()
allowAllIpv6Outbound
(Boolean allowAllIpv6Outbound) Sets the value ofFunctionOptions.getAllowAllIpv6Outbound()
allowAllOutbound
(Boolean allowAllOutbound) Sets the value ofFunctionOptions.getAllowAllOutbound()
allowPublicSubnet
(Boolean allowPublicSubnet) Sets the value ofFunctionOptions.getAllowPublicSubnet()
applicationLogLevel
(String applicationLogLevel) Deprecated.Use `applicationLogLevelV2` as a property instead.applicationLogLevelV2
(ApplicationLogLevel applicationLogLevelV2) Sets the value ofFunctionOptions.getApplicationLogLevelV2()
architecture
(Architecture architecture) Sets the value ofFunctionOptions.getArchitecture()
build()
Builds the configured instance.codeSigningConfig
(ICodeSigningConfig codeSigningConfig) Sets the value ofFunctionOptions.getCodeSigningConfig()
currentVersionOptions
(VersionOptions currentVersionOptions) Sets the value ofFunctionOptions.getCurrentVersionOptions()
deadLetterQueue
(IQueue deadLetterQueue) Sets the value ofFunctionOptions.getDeadLetterQueue()
deadLetterQueueEnabled
(Boolean deadLetterQueueEnabled) Sets the value ofFunctionOptions.getDeadLetterQueueEnabled()
deadLetterTopic
(ITopic deadLetterTopic) Sets the value ofFunctionOptions.getDeadLetterTopic()
description
(String description) Sets the value ofFunctionOptions.getDescription()
environment
(Map<String, String> environment) Sets the value ofFunctionOptions.getEnvironment()
environmentEncryption
(IKey environmentEncryption) Sets the value ofFunctionOptions.getEnvironmentEncryption()
ephemeralStorageSize
(Size ephemeralStorageSize) Sets the value ofFunctionOptions.getEphemeralStorageSize()
events
(List<? extends IEventSource> events) Sets the value ofFunctionOptions.getEvents()
filesystem
(FileSystem filesystem) Sets the value ofFunctionOptions.getFilesystem()
functionName
(String functionName) Sets the value ofFunctionOptions.getFunctionName()
initialPolicy
(List<? extends PolicyStatement> initialPolicy) Sets the value ofFunctionOptions.getInitialPolicy()
insightsVersion
(LambdaInsightsVersion insightsVersion) Sets the value ofFunctionOptions.getInsightsVersion()
ipv6AllowedForDualStack
(Boolean ipv6AllowedForDualStack) Sets the value ofFunctionOptions.getIpv6AllowedForDualStack()
layers
(List<? extends ILayerVersion> layers) Sets the value ofFunctionOptions.getLayers()
Deprecated.Use `loggingFormat` as a property instead.loggingFormat
(LoggingFormat loggingFormat) Sets the value ofFunctionOptions.getLoggingFormat()
Sets the value ofFunctionOptions.getLogGroup()
logRetention
(RetentionDays logRetention) Sets the value ofFunctionOptions.getLogRetention()
logRetentionRetryOptions
(LogRetentionRetryOptions logRetentionRetryOptions) Sets the value ofFunctionOptions.getLogRetentionRetryOptions()
logRetentionRole
(IRole logRetentionRole) Sets the value ofFunctionOptions.getLogRetentionRole()
maxEventAge
(Duration maxEventAge) Sets the value ofEventInvokeConfigOptions.getMaxEventAge()
memorySize
(Number memorySize) Sets the value ofFunctionOptions.getMemorySize()
onFailure
(IDestination onFailure) Sets the value ofEventInvokeConfigOptions.getOnFailure()
onSuccess
(IDestination onSuccess) Sets the value ofEventInvokeConfigOptions.getOnSuccess()
paramsAndSecrets
(ParamsAndSecretsLayerVersion paramsAndSecrets) Sets the value ofFunctionOptions.getParamsAndSecrets()
Sets the value ofFunctionOptions.getProfiling()
profilingGroup
(IProfilingGroup profilingGroup) Sets the value ofFunctionOptions.getProfilingGroup()
recursiveLoop
(RecursiveLoop recursiveLoop) Sets the value ofFunctionOptions.getRecursiveLoop()
reservedConcurrentExecutions
(Number reservedConcurrentExecutions) Sets the value ofFunctionOptions.getReservedConcurrentExecutions()
retryAttempts
(Number retryAttempts) Sets the value ofEventInvokeConfigOptions.getRetryAttempts()
Sets the value ofFunctionOptions.getRole()
runtimeManagementMode
(RuntimeManagementMode runtimeManagementMode) Sets the value ofFunctionOptions.getRuntimeManagementMode()
securityGroups
(List<? extends ISecurityGroup> securityGroups) Sets the value ofFunctionOptions.getSecurityGroups()
snapStart
(SnapStartConf snapStart) Sets the value ofFunctionOptions.getSnapStart()
systemLogLevel
(String systemLogLevel) Deprecated.Use `systemLogLevelV2` as a property instead.systemLogLevelV2
(SystemLogLevel systemLogLevelV2) Sets the value ofFunctionOptions.getSystemLogLevelV2()
Sets the value ofFunctionOptions.getTimeout()
Sets the value ofFunctionOptions.getTracing()
Sets the value ofFunctionOptions.getVpc()
vpcSubnets
(SubnetSelection vpcSubnets) Sets the value ofFunctionOptions.getVpcSubnets()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
adotInstrumentation
@Stability(Stable) public FunctionOptions.Builder adotInstrumentation(AdotInstrumentationConfig adotInstrumentation) Sets the value ofFunctionOptions.getAdotInstrumentation()
- Parameters:
adotInstrumentation
- Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.- Returns:
this
-
allowAllIpv6Outbound
@Stability(Stable) public FunctionOptions.Builder allowAllIpv6Outbound(Boolean allowAllIpv6Outbound) Sets the value ofFunctionOptions.getAllowAllIpv6Outbound()
- Parameters:
allowAllIpv6Outbound
- Whether to allow the Lambda to send all ipv6 network traffic. If set to true, there will only be a single egress rule which allows all outbound ipv6 traffic. If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets using ipv6.Do not specify this property if the
securityGroups
orsecurityGroup
property is set. Instead, configureallowAllIpv6Outbound
directly on the security group.- Returns:
this
-
allowAllOutbound
Sets the value ofFunctionOptions.getAllowAllOutbound()
- Parameters:
allowAllOutbound
- Whether to allow the Lambda to send all network traffic (except ipv6). If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets.Do not specify this property if the
securityGroups
orsecurityGroup
property is set. Instead, configureallowAllOutbound
directly on the security group.- Returns:
this
-
allowPublicSubnet
Sets the value ofFunctionOptions.getAllowPublicSubnet()
- Parameters:
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.- Returns:
this
-
applicationLogLevel
@Stability(Deprecated) @Deprecated public FunctionOptions.Builder applicationLogLevel(String applicationLogLevel) Deprecated.Use `applicationLogLevelV2` as a property instead.Sets the value ofFunctionOptions.getApplicationLogLevel()
- Parameters:
applicationLogLevel
- Sets the application log level for the function.- Returns:
this
-
applicationLogLevelV2
@Stability(Stable) public FunctionOptions.Builder applicationLogLevelV2(ApplicationLogLevel applicationLogLevelV2) Sets the value ofFunctionOptions.getApplicationLogLevelV2()
- Parameters:
applicationLogLevelV2
- Sets the application log level for the function.- Returns:
this
-
architecture
Sets the value ofFunctionOptions.getArchitecture()
- Parameters:
architecture
- The system architectures compatible with this lambda function.- Returns:
this
-
codeSigningConfig
@Stability(Stable) public FunctionOptions.Builder codeSigningConfig(ICodeSigningConfig codeSigningConfig) Sets the value ofFunctionOptions.getCodeSigningConfig()
- Parameters:
codeSigningConfig
- Code signing config associated with this function.- Returns:
this
-
currentVersionOptions
@Stability(Stable) public FunctionOptions.Builder currentVersionOptions(VersionOptions currentVersionOptions) Sets the value ofFunctionOptions.getCurrentVersionOptions()
- Parameters:
currentVersionOptions
- Options for thelambda.Version
resource automatically created by thefn.currentVersion
method.- Returns:
this
-
deadLetterQueue
Sets the value ofFunctionOptions.getDeadLetterQueue()
- Parameters:
deadLetterQueue
- The SQS queue to use if DLQ is enabled. If SNS topic is desired, specifydeadLetterTopic
property instead.- Returns:
this
-
deadLetterQueueEnabled
@Stability(Stable) public FunctionOptions.Builder deadLetterQueueEnabled(Boolean deadLetterQueueEnabled) Sets the value ofFunctionOptions.getDeadLetterQueueEnabled()
- Parameters:
deadLetterQueueEnabled
- Enabled DLQ. IfdeadLetterQueue
is undefined, an SQS queue with default options will be defined for your Function.- Returns:
this
-
deadLetterTopic
Sets the value ofFunctionOptions.getDeadLetterTopic()
- Parameters:
deadLetterTopic
- The SNS topic to use as a DLQ. Note that ifdeadLetterQueueEnabled
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.- Returns:
this
-
description
Sets the value ofFunctionOptions.getDescription()
- Parameters:
description
- A description of the function.- Returns:
this
-
environment
Sets the value ofFunctionOptions.getEnvironment()
- Parameters:
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.- Returns:
this
-
environmentEncryption
Sets the value ofFunctionOptions.getEnvironmentEncryption()
- Parameters:
environmentEncryption
- The AWS KMS key that's used to encrypt your function's environment variables.- Returns:
this
-
ephemeralStorageSize
Sets the value ofFunctionOptions.getEphemeralStorageSize()
- Parameters:
ephemeralStorageSize
- The size of the function’s /tmp directory in MiB.- Returns:
this
-
events
Sets the value ofFunctionOptions.getEvents()
- Parameters:
events
- Event sources for this function. You can also add event sources usingaddEventSource
.- Returns:
this
-
filesystem
Sets the value ofFunctionOptions.getFilesystem()
- Parameters:
filesystem
- The filesystem configuration for the lambda function.- Returns:
this
-
functionName
Sets the value ofFunctionOptions.getFunctionName()
- Parameters:
functionName
- A name for the function.- Returns:
this
-
initialPolicy
@Stability(Stable) public FunctionOptions.Builder initialPolicy(List<? extends PolicyStatement> initialPolicy) Sets the value ofFunctionOptions.getInitialPolicy()
- Parameters:
initialPolicy
- Initial policy statements to add to the created Lambda Role. You can calladdToRolePolicy
to the created lambda to add statements post creation.- Returns:
this
-
insightsVersion
@Stability(Stable) public FunctionOptions.Builder insightsVersion(LambdaInsightsVersion insightsVersion) Sets the value ofFunctionOptions.getInsightsVersion()
- Parameters:
insightsVersion
- Specify the version of CloudWatch Lambda insights to use for monitoring.- Returns:
this
-
ipv6AllowedForDualStack
@Stability(Stable) public FunctionOptions.Builder ipv6AllowedForDualStack(Boolean ipv6AllowedForDualStack) Sets the value ofFunctionOptions.getIpv6AllowedForDualStack()
- Parameters:
ipv6AllowedForDualStack
- Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets. Only used if 'vpc' is supplied.- Returns:
this
-
layers
Sets the value ofFunctionOptions.getLayers()
- Parameters:
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.- Returns:
this
-
logFormat
Deprecated.Use `loggingFormat` as a property instead.Sets the value ofFunctionOptions.getLogFormat()
- Parameters:
logFormat
- Sets the logFormat for the function.- Returns:
this
-
loggingFormat
Sets the value ofFunctionOptions.getLoggingFormat()
- Parameters:
loggingFormat
- Sets the loggingFormat for the function.- Returns:
this
-
logGroup
Sets the value ofFunctionOptions.getLogGroup()
- Parameters:
logGroup
- The log group the function sends logs to. By default, Lambda functions send logs to an automatically created default log group named /aws/lambda/. However you cannot change the properties of this auto-created log group using the AWS CDK, e.g. you cannot set a different log retention. Use the
logGroup
property to create a fully customizable LogGroup ahead of time, and instruct the Lambda function to send logs to it.Providing a user-controlled log group was rolled out to commercial regions on 2023-11-16. If you are deploying to another type of region, please check regional availability first.
- Returns:
this
-
logRetention
Sets the value ofFunctionOptions.getLogRetention()
- Parameters:
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 toINFINITE
.This is a legacy API and we strongly recommend you move away from it if you can. Instead create a fully customizable log group with
logs.LogGroup
and use thelogGroup
property to instruct the Lambda function to send logs to it. Migrating fromlogRetention
tologGroup
will cause the name of the log group to change. Users and code and referencing the name verbatim will have to adjust.In AWS CDK code, you can access the log group name directly from the LogGroup construct:
import software.amazon.awscdk.services.logs.*; LogGroup myLogGroup; myLogGroup.getLogGroupName();
- Returns:
this
-
logRetentionRetryOptions
@Stability(Stable) public FunctionOptions.Builder logRetentionRetryOptions(LogRetentionRetryOptions logRetentionRetryOptions) Sets the value ofFunctionOptions.getLogRetentionRetryOptions()
- Parameters:
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.This is a legacy API and we strongly recommend you migrate to
logGroup
if you can.logGroup
allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.- Returns:
this
-
logRetentionRole
Sets the value ofFunctionOptions.getLogRetentionRole()
- Parameters:
logRetentionRole
- The IAM role for the Lambda function associated with the custom resource that sets the retention policy. This is a legacy API and we strongly recommend you migrate tologGroup
if you can.logGroup
allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.- Returns:
this
-
memorySize
Sets the value ofFunctionOptions.getMemorySize()
- Parameters:
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.- Returns:
this
-
paramsAndSecrets
@Stability(Stable) public FunctionOptions.Builder paramsAndSecrets(ParamsAndSecretsLayerVersion paramsAndSecrets) Sets the value ofFunctionOptions.getParamsAndSecrets()
- Parameters:
paramsAndSecrets
- Specify the configuration of Parameters and Secrets Extension.- Returns:
this
-
profiling
Sets the value ofFunctionOptions.getProfiling()
- Parameters:
profiling
- Enable profiling.- Returns:
this
-
profilingGroup
Sets the value ofFunctionOptions.getProfilingGroup()
- Parameters:
profilingGroup
- Profiling Group.- Returns:
this
-
recursiveLoop
Sets the value ofFunctionOptions.getRecursiveLoop()
- Parameters:
recursiveLoop
- Sets the Recursive Loop Protection for Lambda Function. It lets Lambda detect and terminate unintended recursive loops.- Returns:
this
-
reservedConcurrentExecutions
@Stability(Stable) public FunctionOptions.Builder reservedConcurrentExecutions(Number reservedConcurrentExecutions) Sets the value ofFunctionOptions.getReservedConcurrentExecutions()
- Parameters:
reservedConcurrentExecutions
- The maximum of concurrent executions you want to reserve for the function.- Returns:
this
-
role
Sets the value ofFunctionOptions.getRole()
- Parameters:
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".
- Returns:
this
-
runtimeManagementMode
@Stability(Stable) public FunctionOptions.Builder runtimeManagementMode(RuntimeManagementMode runtimeManagementMode) Sets the value ofFunctionOptions.getRuntimeManagementMode()
- Parameters:
runtimeManagementMode
- Sets the runtime management configuration for a function's version.- Returns:
this
-
securityGroups
@Stability(Stable) public FunctionOptions.Builder securityGroups(List<? extends ISecurityGroup> securityGroups) Sets the value ofFunctionOptions.getSecurityGroups()
- Parameters:
securityGroups
- The list of security groups to associate with the Lambda's network interfaces. Only used if 'vpc' is supplied.- Returns:
this
-
snapStart
Sets the value ofFunctionOptions.getSnapStart()
- Parameters:
snapStart
- Enable SnapStart for Lambda Function. SnapStart is currently supported for Java 11, Java 17, Python 3.12, Python 3.13, and .NET 8 runtime- Returns:
this
-
systemLogLevel
@Stability(Deprecated) @Deprecated public FunctionOptions.Builder systemLogLevel(String systemLogLevel) Deprecated.Use `systemLogLevelV2` as a property instead.Sets the value ofFunctionOptions.getSystemLogLevel()
- Parameters:
systemLogLevel
- Sets the system log level for the function.- Returns:
this
-
systemLogLevelV2
Sets the value ofFunctionOptions.getSystemLogLevelV2()
- Parameters:
systemLogLevelV2
- Sets the system log level for the function.- Returns:
this
-
timeout
Sets the value ofFunctionOptions.getTimeout()
- Parameters:
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.- Returns:
this
-
tracing
Sets the value ofFunctionOptions.getTracing()
- Parameters:
tracing
- Enable AWS X-Ray Tracing for Lambda Function.- Returns:
this
-
vpc
Sets the value ofFunctionOptions.getVpc()
- Parameters:
vpc
- VPC network to place Lambda network interfaces. Specify this if the Lambda function needs to access resources in a VPC. This is required whenvpcSubnets
is specified.- Returns:
this
-
vpcSubnets
Sets the value ofFunctionOptions.getVpcSubnets()
- Parameters:
vpcSubnets
- Where to place the network interfaces within the VPC. This requiresvpc
to be specified in order for interfaces to actually be placed in the subnets. Ifvpc
is not specify, this will raise an error.Note: Internet access for Lambda Functions requires a NAT Gateway, so picking public subnets is not allowed (unless
allowPublicSubnet
is set totrue
).- Returns:
this
-
maxEventAge
Sets the value ofEventInvokeConfigOptions.getMaxEventAge()
- Parameters:
maxEventAge
- The maximum age of a request that Lambda sends to a function for processing. Minimum: 60 seconds Maximum: 6 hours- Returns:
this
-
onFailure
Sets the value ofEventInvokeConfigOptions.getOnFailure()
- Parameters:
onFailure
- The destination for failed invocations.- Returns:
this
-
onSuccess
Sets the value ofEventInvokeConfigOptions.getOnSuccess()
- Parameters:
onSuccess
- The destination for successful invocations.- Returns:
this
-
retryAttempts
Sets the value ofEventInvokeConfigOptions.getRetryAttempts()
- Parameters:
retryAttempts
- The maximum number of times to retry when the function returns an error. Minimum: 0 Maximum: 2- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<FunctionOptions>
- Returns:
- a new instance of
FunctionOptions
- Throws:
NullPointerException
- if any required attribute was not provided
-