Interface FunctionOptions

All Superinterfaces:
EventInvokeConfigOptions, software.amazon.jsii.JsiiSerializable
All Known Subinterfaces:
DockerImageFunctionProps, EdgeFunctionProps, FunctionProps, GoFunctionProps, NodejsFunctionProps, PythonFunctionProps, SingletonFunctionProps, TriggerFunctionProps
All Known Implementing Classes:
DockerImageFunctionProps.Jsii$Proxy, EdgeFunctionProps.Jsii$Proxy, FunctionOptions.Jsii$Proxy, FunctionProps.Jsii$Proxy, GoFunctionProps.Jsii$Proxy, NodejsFunctionProps.Jsii$Proxy, PythonFunctionProps.Jsii$Proxy, SingletonFunctionProps.Jsii$Proxy, TriggerFunctionProps.Jsii$Proxy

@Generated(value="jsii-pacmak/1.103.1 (build bef2dea)", date="2024-10-25T14:21:17.666Z") @Stability(Stable) public interface FunctionOptions extends software.amazon.jsii.JsiiSerializable, EventInvokeConfigOptions
Non runtime options.

Example:

 // The code below shows an example of how to instantiate this type.
 // The values are placeholders you should change.
 import software.amazon.awscdk.*;
 import software.amazon.awscdk.services.codeguruprofiler.*;
 import software.amazon.awscdk.services.ec2.*;
 import software.amazon.awscdk.services.iam.*;
 import software.amazon.awscdk.services.kms.*;
 import software.amazon.awscdk.services.lambda.*;
 import software.amazon.awscdk.services.logs.*;
 import software.amazon.awscdk.services.sns.*;
 import software.amazon.awscdk.services.sqs.*;
 AdotLayerVersion adotLayerVersion;
 Architecture architecture;
 CodeSigningConfig codeSigningConfig;
 IDestination destination;
 IEventSource eventSource;
 FileSystem fileSystem;
 Key key;
 LambdaInsightsVersion lambdaInsightsVersion;
 LayerVersion layerVersion;
 LogGroup logGroup;
 ParamsAndSecretsLayerVersion paramsAndSecretsLayerVersion;
 PolicyStatement policyStatement;
 ProfilingGroup profilingGroup;
 Queue queue;
 Role role;
 RuntimeManagementMode runtimeManagementMode;
 SecurityGroup securityGroup;
 Size size;
 SnapStartConf snapStartConf;
 Subnet subnet;
 SubnetFilter subnetFilter;
 Topic topic;
 Vpc vpc;
 FunctionOptions functionOptions = FunctionOptions.builder()
         .adotInstrumentation(AdotInstrumentationConfig.builder()
                 .execWrapper(AdotLambdaExecWrapper.REGULAR_HANDLER)
                 .layerVersion(adotLayerVersion)
                 .build())
         .allowAllIpv6Outbound(false)
         .allowAllOutbound(false)
         .allowPublicSubnet(false)
         .applicationLogLevel("applicationLogLevel")
         .applicationLogLevelV2(ApplicationLogLevel.INFO)
         .architecture(architecture)
         .codeSigningConfig(codeSigningConfig)
         .currentVersionOptions(VersionOptions.builder()
                 .codeSha256("codeSha256")
                 .description("description")
                 .maxEventAge(Duration.minutes(30))
                 .onFailure(destination)
                 .onSuccess(destination)
                 .provisionedConcurrentExecutions(123)
                 .removalPolicy(RemovalPolicy.DESTROY)
                 .retryAttempts(123)
                 .build())
         .deadLetterQueue(queue)
         .deadLetterQueueEnabled(false)
         .deadLetterTopic(topic)
         .description("description")
         .environment(Map.of(
                 "environmentKey", "environment"))
         .environmentEncryption(key)
         .ephemeralStorageSize(size)
         .events(List.of(eventSource))
         .filesystem(fileSystem)
         .functionName("functionName")
         .initialPolicy(List.of(policyStatement))
         .insightsVersion(lambdaInsightsVersion)
         .ipv6AllowedForDualStack(false)
         .layers(List.of(layerVersion))
         .logFormat("logFormat")
         .loggingFormat(LoggingFormat.TEXT)
         .logGroup(logGroup)
         .logRetention(RetentionDays.ONE_DAY)
         .logRetentionRetryOptions(LogRetentionRetryOptions.builder()
                 .base(Duration.minutes(30))
                 .maxRetries(123)
                 .build())
         .logRetentionRole(role)
         .maxEventAge(Duration.minutes(30))
         .memorySize(123)
         .onFailure(destination)
         .onSuccess(destination)
         .paramsAndSecrets(paramsAndSecretsLayerVersion)
         .profiling(false)
         .profilingGroup(profilingGroup)
         .recursiveLoop(RecursiveLoop.ALLOW)
         .reservedConcurrentExecutions(123)
         .retryAttempts(123)
         .role(role)
         .runtimeManagementMode(runtimeManagementMode)
         .securityGroups(List.of(securityGroup))
         .snapStart(snapStartConf)
         .systemLogLevel("systemLogLevel")
         .systemLogLevelV2(SystemLogLevel.INFO)
         .timeout(Duration.minutes(30))
         .tracing(Tracing.ACTIVE)
         .vpc(vpc)
         .vpcSubnets(SubnetSelection.builder()
                 .availabilityZones(List.of("availabilityZones"))
                 .onePerAz(false)
                 .subnetFilters(List.of(subnetFilter))
                 .subnetGroupName("subnetGroupName")
                 .subnets(List.of(subnet))
                 .subnetType(SubnetType.PRIVATE_ISOLATED)
                 .build())
         .build();
 
  • Method Details

    • getAdotInstrumentation

      @Stability(Stable) @Nullable default AdotInstrumentationConfig getAdotInstrumentation()
      Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.

      Default: - No ADOT instrumentation

      See Also:
    • getAllowAllIpv6Outbound

      @Stability(Stable) @Nullable default Boolean getAllowAllIpv6Outbound()
      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 or securityGroup property is set. Instead, configure allowAllIpv6Outbound directly on the security group.

      Default: false

    • getAllowAllOutbound

      @Stability(Stable) @Nullable default Boolean getAllowAllOutbound()
      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 or securityGroup property is set. Instead, configure allowAllOutbound directly on the security group.

      Default: true

    • getAllowPublicSubnet

      @Stability(Stable) @Nullable default Boolean getAllowPublicSubnet()
      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

      See Also:
    • getApplicationLogLevel

      @Stability(Deprecated) @Deprecated @Nullable default String getApplicationLogLevel()
      Deprecated.
      Use applicationLogLevelV2 as a property instead.
      (deprecated) Sets the application log level for the function.

      Default: "INFO"

    • getApplicationLogLevelV2

      @Stability(Stable) @Nullable default ApplicationLogLevel getApplicationLogLevelV2()
      Sets the application log level for the function.

      Default: ApplicationLogLevel.INFO

    • getArchitecture

      @Stability(Stable) @Nullable default Architecture getArchitecture()
      The system architectures compatible with this lambda function.

      Default: Architecture.X86_64

    • getCodeSigningConfig

      @Stability(Stable) @Nullable default ICodeSigningConfig getCodeSigningConfig()
      Code signing config associated with this function.

      Default: - Not Sign the Code

    • getCurrentVersionOptions

      @Stability(Stable) @Nullable default VersionOptions getCurrentVersionOptions()
      Options for the lambda.Version resource automatically created by the fn.currentVersion method.

      Default: - default options as described in `VersionOptions`

    • getDeadLetterQueue

      @Stability(Stable) @Nullable default IQueue getDeadLetterQueue()
      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`

    • getDeadLetterQueueEnabled

      @Stability(Stable) @Nullable default Boolean getDeadLetterQueueEnabled()
      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.

    • getDeadLetterTopic

      @Stability(Stable) @Nullable default ITopic getDeadLetterTopic()
      The SNS topic to use as a DLQ.

      Note that if deadLetterQueueEnabled is set to true, 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

    • getDescription

      @Stability(Stable) @Nullable default String getDescription()
      A description of the function.

      Default: - No description.

    • getEnvironment

      @Stability(Stable) @Nullable default Map<String,String> getEnvironment()
      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.

    • getEnvironmentEncryption

      @Stability(Stable) @Nullable default IKey getEnvironmentEncryption()
      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).

    • getEphemeralStorageSize

      @Stability(Stable) @Nullable default Size getEphemeralStorageSize()
      The size of the function’s /tmp directory in MiB.

      Default: 512 MiB

    • getEvents

      @Stability(Stable) @Nullable default List<IEventSource> getEvents()
      Event sources for this function.

      You can also add event sources using addEventSource.

      Default: - No event sources.

    • getFilesystem

      @Stability(Stable) @Nullable default FileSystem getFilesystem()
      The filesystem configuration for the lambda function.

      Default: - will not mount any filesystem

    • getFunctionName

      @Stability(Stable) @Nullable default String getFunctionName()
      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.

    • getInitialPolicy

      @Stability(Stable) @Nullable default List<PolicyStatement> getInitialPolicy()
      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.

    • getInsightsVersion

      @Stability(Stable) @Nullable default LambdaInsightsVersion getInsightsVersion()
      Specify the version of CloudWatch Lambda insights to use for monitoring.

      Default: - No Lambda Insights

      See Also:
    • getIpv6AllowedForDualStack

      @Stability(Stable) @Nullable default Boolean getIpv6AllowedForDualStack()
      Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.

      Only used if 'vpc' is supplied.

      Default: false

    • getLayers

      @Stability(Stable) @Nullable default List<ILayerVersion> getLayers()
      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.

    • getLogFormat

      @Stability(Deprecated) @Deprecated @Nullable default String getLogFormat()
      Deprecated.
      Use loggingFormat as a property instead.
      (deprecated) Sets the logFormat for the function.

      Default: "Text"

    • getLoggingFormat

      @Stability(Stable) @Nullable default LoggingFormat getLoggingFormat()
      Sets the loggingFormat for the function.

      Default: LoggingFormat.TEXT

    • getLogGroup

      @Stability(Stable) @Nullable default ILogGroup getLogGroup()
      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.

      Default: `/aws/lambda/${this.functionName}` - default log group created by Lambda

    • getLogRetention

      @Stability(Stable) @Nullable default RetentionDays getLogRetention()
      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.

      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 the logGroup property to instruct the Lambda function to send logs to it. Migrating from logRetention to logGroup 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();
       

      Default: logs.RetentionDays.INFINITE

    • getLogRetentionRetryOptions

      @Stability(Stable) @Nullable default LogRetentionRetryOptions getLogRetentionRetryOptions()
      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.

      Default: - Default AWS SDK retry options.

    • getLogRetentionRole

      @Stability(Stable) @Nullable default IRole getLogRetentionRole()
      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 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.

      Default: - A new role is created.

    • getMemorySize

      @Stability(Stable) @Nullable default Number getMemorySize()
      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

    • getParamsAndSecrets

      @Stability(Stable) @Nullable default ParamsAndSecretsLayerVersion getParamsAndSecrets()
      Specify the configuration of Parameters and Secrets Extension.

      Default: - No Parameters and Secrets Extension

      See Also:
    • getProfiling

      @Stability(Stable) @Nullable default Boolean getProfiling()
      Enable profiling.

      Default: - No profiling.

      See Also:
    • getProfilingGroup

      @Stability(Stable) @Nullable default IProfilingGroup getProfilingGroup()
      Profiling Group.

      Default: - A new profiling group will be created if `profiling` is set.

      See Also:
    • getRecursiveLoop

      @Stability(Stable) @Nullable default RecursiveLoop getRecursiveLoop()
      Sets the Recursive Loop Protection for Lambda Function.

      It lets Lambda detect and terminate unintended recursive loops.

      Default: RecursiveLoop.Terminate

    • getReservedConcurrentExecutions

      @Stability(Stable) @Nullable default Number getReservedConcurrentExecutions()
      The maximum of concurrent executions you want to reserve for the function.

      Default: - No specific limit - account limit.

      See Also:
    • getRole

      @Stability(Stable) @Nullable default IRole getRole()
      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`.

    • getRuntimeManagementMode

      @Stability(Stable) @Nullable default RuntimeManagementMode getRuntimeManagementMode()
      Sets the runtime management configuration for a function's version.

      Default: Auto

    • getSecurityGroups

      @Stability(Stable) @Nullable default List<ISecurityGroup> getSecurityGroups()
      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.

    • getSnapStart

      @Stability(Stable) @Nullable default SnapStartConf getSnapStart()
      Enable SnapStart for Lambda Function.

      SnapStart is currently supported only for Java 11, 17 runtime

      Default: - No snapstart

    • getSystemLogLevel

      @Stability(Deprecated) @Deprecated @Nullable default String getSystemLogLevel()
      Deprecated.
      Use systemLogLevelV2 as a property instead.
      (deprecated) Sets the system log level for the function.

      Default: "INFO"

    • getSystemLogLevelV2

      @Stability(Stable) @Nullable default SystemLogLevel getSystemLogLevelV2()
      Sets the system log level for the function.

      Default: SystemLogLevel.INFO

    • getTimeout

      @Stability(Stable) @Nullable default Duration getTimeout()
      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)

    • getTracing

      @Stability(Stable) @Nullable default Tracing getTracing()
      Enable AWS X-Ray Tracing for Lambda Function.

      Default: Tracing.Disabled

    • getVpc

      @Stability(Stable) @Nullable default IVpc getVpc()
      VPC network to place Lambda network interfaces.

      Specify this if the Lambda function needs to access resources in a VPC. This is required when vpcSubnets is specified.

      Default: - Function is not placed within a VPC.

    • getVpcSubnets

      @Stability(Stable) @Nullable default SubnetSelection getVpcSubnets()
      Where to place the network interfaces within the VPC.

      This requires vpc to be specified in order for interfaces to actually be placed in the subnets. If vpc 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 to true).

      Default: - the Vpc default strategy if not specified

    • builder

      @Stability(Stable) static FunctionOptions.Builder builder()
      Returns:
      a FunctionOptions.Builder of FunctionOptions