Class PythonFunctionProps.Builder

java.lang.Object
software.amazon.awscdk.services.lambda.python.PythonFunctionProps.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<PythonFunctionProps>
Enclosing interface:
PythonFunctionProps

@Stability(Experimental) public static final class PythonFunctionProps.Builder extends Object implements software.amazon.jsii.Builder<PythonFunctionProps>
A builder for PythonFunctionProps
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • entry

      @Stability(Experimental) public PythonFunctionProps.Builder entry(String entry)
      Parameters:
      entry - Path to the source of the function or the location for dependencies. This parameter is required.
      Returns:
      this
    • runtime

      @Stability(Experimental) public PythonFunctionProps.Builder runtime(software.amazon.awscdk.services.lambda.Runtime runtime)
      Parameters:
      runtime - The runtime environment. This parameter is required. Only runtimes of the Python family are supported.
      Returns:
      this
    • bundling

      @Stability(Experimental) public PythonFunctionProps.Builder bundling(BundlingOptions bundling)
      Parameters:
      bundling - Bundling options to use for this function. Use this to specify custom bundling options like the bundling Docker image, asset hash type, custom hash, architecture, etc.
      Returns:
      this
    • handler

      @Stability(Experimental) public PythonFunctionProps.Builder handler(String handler)
      Parameters:
      handler - The name of the exported handler in the index file.
      Returns:
      this
    • index

      @Stability(Experimental) public PythonFunctionProps.Builder index(String index)
      Parameters:
      index - The path (relative to entry) to the index file containing the exported handler.
      Returns:
      this
    • allowAllOutbound

      @Stability(Stable) public PythonFunctionProps.Builder allowAllOutbound(Boolean allowAllOutbound)
      Sets the value of FunctionOptions.getAllowAllOutbound()
      Parameters:
      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.
      Returns:
      this
    • allowPublicSubnet

      @Stability(Stable) public PythonFunctionProps.Builder allowPublicSubnet(Boolean allowPublicSubnet)
      Sets the value of FunctionOptions.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
    • architecture

      @Stability(Stable) public PythonFunctionProps.Builder architecture(software.amazon.awscdk.services.lambda.Architecture architecture)
      Sets the value of FunctionOptions.getArchitecture()
      Parameters:
      architecture - The system architectures compatible with this lambda function.
      Returns:
      this
    • architectures

      @Stability(Deprecated) @Deprecated public PythonFunctionProps.Builder architectures(List<? extends software.amazon.awscdk.services.lambda.Architecture> architectures)
      Deprecated.
      use `architecture`
      Sets the value of FunctionOptions.getArchitectures()
      Parameters:
      architectures - DEPRECATED.
      Returns:
      this
    • codeSigningConfig

      @Stability(Stable) public PythonFunctionProps.Builder codeSigningConfig(software.amazon.awscdk.services.lambda.ICodeSigningConfig codeSigningConfig)
      Sets the value of FunctionOptions.getCodeSigningConfig()
      Parameters:
      codeSigningConfig - Code signing config associated with this function.
      Returns:
      this
    • currentVersionOptions

      @Stability(Stable) public PythonFunctionProps.Builder currentVersionOptions(software.amazon.awscdk.services.lambda.VersionOptions currentVersionOptions)
      Sets the value of FunctionOptions.getCurrentVersionOptions()
      Parameters:
      currentVersionOptions - Options for the `lambda.Version` resource automatically created by the `fn.currentVersion` method.
      Returns:
      this
    • deadLetterQueue

      @Stability(Stable) public PythonFunctionProps.Builder deadLetterQueue(software.amazon.awscdk.services.sqs.IQueue deadLetterQueue)
      Sets the value of FunctionOptions.getDeadLetterQueue()
      Parameters:
      deadLetterQueue - The SQS queue to use if DLQ is enabled. If SNS topic is desired, specify deadLetterTopic property instead.
      Returns:
      this
    • deadLetterQueueEnabled

      @Stability(Stable) public PythonFunctionProps.Builder deadLetterQueueEnabled(Boolean deadLetterQueueEnabled)
      Sets the value of FunctionOptions.getDeadLetterQueueEnabled()
      Parameters:
      deadLetterQueueEnabled - Enabled DLQ. If deadLetterQueue is undefined, an SQS queue with default options will be defined for your Function.
      Returns:
      this
    • deadLetterTopic

      @Stability(Stable) public PythonFunctionProps.Builder deadLetterTopic(software.amazon.awscdk.services.sns.ITopic deadLetterTopic)
      Sets the value of FunctionOptions.getDeadLetterTopic()
      Parameters:
      deadLetterTopic - 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.
      Returns:
      this
    • description

      @Stability(Stable) public PythonFunctionProps.Builder description(String description)
      Sets the value of FunctionOptions.getDescription()
      Parameters:
      description - A description of the function.
      Returns:
      this
    • environment

      @Stability(Stable) public PythonFunctionProps.Builder environment(Map<String,String> environment)
      Sets the value of FunctionOptions.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

      @Stability(Stable) public PythonFunctionProps.Builder environmentEncryption(software.amazon.awscdk.services.kms.IKey environmentEncryption)
      Sets the value of FunctionOptions.getEnvironmentEncryption()
      Parameters:
      environmentEncryption - The AWS KMS key that's used to encrypt your function's environment variables.
      Returns:
      this
    • ephemeralStorageSize

      @Stability(Stable) public PythonFunctionProps.Builder ephemeralStorageSize(software.amazon.awscdk.core.Size ephemeralStorageSize)
      Sets the value of FunctionOptions.getEphemeralStorageSize()
      Parameters:
      ephemeralStorageSize - The size of the function’s /tmp directory in MiB.
      Returns:
      this
    • events

      @Stability(Stable) public PythonFunctionProps.Builder events(List<? extends software.amazon.awscdk.services.lambda.IEventSource> events)
      Sets the value of FunctionOptions.getEvents()
      Parameters:
      events - Event sources for this function. You can also add event sources using addEventSource.
      Returns:
      this
    • filesystem

      @Stability(Stable) public PythonFunctionProps.Builder filesystem(software.amazon.awscdk.services.lambda.FileSystem filesystem)
      Sets the value of FunctionOptions.getFilesystem()
      Parameters:
      filesystem - The filesystem configuration for the lambda function.
      Returns:
      this
    • functionName

      @Stability(Stable) public PythonFunctionProps.Builder functionName(String functionName)
      Sets the value of FunctionOptions.getFunctionName()
      Parameters:
      functionName - A name for the function.
      Returns:
      this
    • initialPolicy

      @Stability(Stable) public PythonFunctionProps.Builder initialPolicy(List<? extends software.amazon.awscdk.services.iam.PolicyStatement> initialPolicy)
      Sets the value of FunctionOptions.getInitialPolicy()
      Parameters:
      initialPolicy - Initial policy statements to add to the created Lambda Role. You can call addToRolePolicy to the created lambda to add statements post creation.
      Returns:
      this
    • insightsVersion

      @Stability(Stable) public PythonFunctionProps.Builder insightsVersion(software.amazon.awscdk.services.lambda.LambdaInsightsVersion insightsVersion)
      Sets the value of FunctionOptions.getInsightsVersion()
      Parameters:
      insightsVersion - Specify the version of CloudWatch Lambda insights to use for monitoring.
      Returns:
      this
    • layers

      @Stability(Stable) public PythonFunctionProps.Builder layers(List<? extends software.amazon.awscdk.services.lambda.ILayerVersion> layers)
      Sets the value of FunctionOptions.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
    • logRetention

      @Stability(Stable) public PythonFunctionProps.Builder logRetention(software.amazon.awscdk.services.logs.RetentionDays logRetention)
      Sets the value of FunctionOptions.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 to INFINITE.
      Returns:
      this
    • logRetentionRetryOptions

      @Stability(Stable) public PythonFunctionProps.Builder logRetentionRetryOptions(software.amazon.awscdk.services.lambda.LogRetentionRetryOptions logRetentionRetryOptions)
      Sets the value of FunctionOptions.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.
      Returns:
      this
    • logRetentionRole

      @Stability(Stable) public PythonFunctionProps.Builder logRetentionRole(software.amazon.awscdk.services.iam.IRole logRetentionRole)
      Sets the value of FunctionOptions.getLogRetentionRole()
      Parameters:
      logRetentionRole - The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
      Returns:
      this
    • memorySize

      @Stability(Stable) public PythonFunctionProps.Builder memorySize(Number memorySize)
      Sets the value of FunctionOptions.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
    • profiling

      @Stability(Stable) public PythonFunctionProps.Builder profiling(Boolean profiling)
      Sets the value of FunctionOptions.getProfiling()
      Parameters:
      profiling - Enable profiling.
      Returns:
      this
    • profilingGroup

      @Stability(Stable) public PythonFunctionProps.Builder profilingGroup(software.amazon.awscdk.services.codeguruprofiler.IProfilingGroup profilingGroup)
      Sets the value of FunctionOptions.getProfilingGroup()
      Parameters:
      profilingGroup - Profiling Group.
      Returns:
      this
    • reservedConcurrentExecutions

      @Stability(Stable) public PythonFunctionProps.Builder reservedConcurrentExecutions(Number reservedConcurrentExecutions)
      Sets the value of FunctionOptions.getReservedConcurrentExecutions()
      Parameters:
      reservedConcurrentExecutions - The maximum of concurrent executions you want to reserve for the function.
      Returns:
      this
    • role

      @Stability(Stable) public PythonFunctionProps.Builder role(software.amazon.awscdk.services.iam.IRole role)
      Sets the value of FunctionOptions.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
    • securityGroup

      @Stability(Deprecated) @Deprecated public PythonFunctionProps.Builder securityGroup(ISecurityGroup securityGroup)
      Deprecated.
      - This property is deprecated, use securityGroups instead
      Sets the value of FunctionOptions.getSecurityGroup()
      Parameters:
      securityGroup - 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.

      Returns:
      this
    • securityGroups

      @Stability(Stable) public PythonFunctionProps.Builder securityGroups(List<? extends ISecurityGroup> securityGroups)
      Sets the value of FunctionOptions.getSecurityGroups()
      Parameters:
      securityGroups - The list of security groups to associate with the Lambda's network interfaces. Only used if 'vpc' is supplied.
      Returns:
      this
    • timeout

      @Stability(Stable) public PythonFunctionProps.Builder timeout(software.amazon.awscdk.core.Duration timeout)
      Sets the value of FunctionOptions.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

      @Stability(Stable) public PythonFunctionProps.Builder tracing(software.amazon.awscdk.services.lambda.Tracing tracing)
      Sets the value of FunctionOptions.getTracing()
      Parameters:
      tracing - Enable AWS X-Ray Tracing for Lambda Function.
      Returns:
      this
    • vpc

      @Stability(Stable) public PythonFunctionProps.Builder vpc(IVpc vpc)
      Sets the value of FunctionOptions.getVpc()
      Parameters:
      vpc - VPC network to place Lambda network interfaces. Specify this if the Lambda function needs to access resources in a VPC.
      Returns:
      this
    • vpcSubnets

      @Stability(Stable) public PythonFunctionProps.Builder vpcSubnets(SubnetSelection vpcSubnets)
      Sets the value of FunctionOptions.getVpcSubnets()
      Parameters:
      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.
      Returns:
      this
    • maxEventAge

      @Stability(Stable) public PythonFunctionProps.Builder maxEventAge(software.amazon.awscdk.core.Duration maxEventAge)
      Sets the value of EventInvokeConfigOptions.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

      @Stability(Stable) public PythonFunctionProps.Builder onFailure(software.amazon.awscdk.services.lambda.IDestination onFailure)
      Sets the value of EventInvokeConfigOptions.getOnFailure()
      Parameters:
      onFailure - The destination for failed invocations.
      Returns:
      this
    • onSuccess

      @Stability(Stable) public PythonFunctionProps.Builder onSuccess(software.amazon.awscdk.services.lambda.IDestination onSuccess)
      Sets the value of EventInvokeConfigOptions.getOnSuccess()
      Parameters:
      onSuccess - The destination for successful invocations.
      Returns:
      this
    • retryAttempts

      @Stability(Stable) public PythonFunctionProps.Builder retryAttempts(Number retryAttempts)
      Sets the value of EventInvokeConfigOptions.getRetryAttempts()
      Parameters:
      retryAttempts - The maximum number of times to retry when the function returns an error. Minimum: 0 Maximum: 2
      Returns:
      this
    • build

      @Stability(Experimental) public PythonFunctionProps build()
      Builds the configured instance.
      Specified by:
      build in interface software.amazon.jsii.Builder<PythonFunctionProps>
      Returns:
      a new instance of PythonFunctionProps
      Throws:
      NullPointerException - if any required attribute was not provided