Class AwsCustomResource.Builder

java.lang.Object
software.amazon.awscdk.customresources.AwsCustomResource.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<AwsCustomResource>
Enclosing class:
AwsCustomResource

@Stability(Stable) public static final class AwsCustomResource.Builder extends Object implements software.amazon.jsii.Builder<AwsCustomResource>
A fluent builder for AwsCustomResource.
  • Method Details

    • create

      @Stability(Stable) public static AwsCustomResource.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of AwsCustomResource.Builder.
    • functionName

      @Stability(Stable) public AwsCustomResource.Builder functionName(String functionName)
      A name for the singleton Lambda function implementing this custom resource.

      The function name will remain the same after the first AwsCustomResource is created in a stack.

      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 singleton Lambda function implementing this custom resource. This parameter is required.
      Returns:
      this
    • installLatestAwsSdk

      @Stability(Stable) public AwsCustomResource.Builder installLatestAwsSdk(Boolean installLatestAwsSdk)
      Whether to install the latest AWS SDK v2.

      If not specified, this uses whatever JavaScript SDK version is the default in AWS Lambda at the time of execution.

      Otherwise, installs the latest version from 'npmjs.com'. The installation takes around 60 seconds and requires internet connectivity.

      The default can be controlled using the context key @aws-cdk/customresources:installLatestAwsSdkDefault is.

      Default: - The value of `@aws-cdk/customresources:installLatestAwsSdkDefault`, otherwise `true`

      Parameters:
      installLatestAwsSdk - Whether to install the latest AWS SDK v2. This parameter is required.
      Returns:
      this
    • logGroup

      @Stability(Stable) public AwsCustomResource.Builder logGroup(ILogGroup logGroup)
      The Log Group used for logging of events emitted by the custom resource's lambda function.

      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: - a default log group created by AWS Lambda

      Parameters:
      logGroup - The Log Group used for logging of events emitted by the custom resource's lambda function. This parameter is required.
      Returns:
      this
    • logRetention

      @Stability(Stable) public AwsCustomResource.Builder logRetention(RetentionDays logRetention)
      The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs.

      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: logs.RetentionDays.INFINITE

      Parameters:
      logRetention - The number of days log events of the singleton Lambda function implementing this custom resource are kept in CloudWatch Logs. This parameter is required.
      Returns:
      this
    • memorySize

      @Stability(Stable) public AwsCustomResource.Builder memorySize(Number memorySize)
      The memory size for the singleton Lambda function implementing this custom resource.

      Default: 512 mega in case if installLatestAwsSdk is false.

      Parameters:
      memorySize - The memory size for the singleton Lambda function implementing this custom resource. This parameter is required.
      Returns:
      this
    • onCreate

      @Stability(Stable) public AwsCustomResource.Builder onCreate(AwsSdkCall onCreate)
      The AWS SDK call to make when the resource is created.

      Default: - the call when the resource is updated

      Parameters:
      onCreate - The AWS SDK call to make when the resource is created. This parameter is required.
      Returns:
      this
    • onDelete

      @Stability(Stable) public AwsCustomResource.Builder onDelete(AwsSdkCall onDelete)
      The AWS SDK call to make when the resource is deleted.

      Default: - no call

      Parameters:
      onDelete - The AWS SDK call to make when the resource is deleted. This parameter is required.
      Returns:
      this
    • onUpdate

      @Stability(Stable) public AwsCustomResource.Builder onUpdate(AwsSdkCall onUpdate)
      The AWS SDK call to make when the resource is updated.

      Default: - no call

      Parameters:
      onUpdate - The AWS SDK call to make when the resource is updated. This parameter is required.
      Returns:
      this
    • policy

      @Stability(Stable) public AwsCustomResource.Builder policy(AwsCustomResourcePolicy policy)
      The policy that will be added to the execution role of the Lambda function implementing this custom resource provider.

      The custom resource also implements iam.IGrantable, making it possible to use the grantXxx() methods.

      As this custom resource uses a singleton Lambda function, it's important to note the that function's role will eventually accumulate the permissions/grants from all resources.

      Note that a policy must be specified if role is not provided, as by default a new role is created which requires policy changes to access resources.

      Default: - no policy added

      Parameters:
      policy - The policy that will be added to the execution role of the Lambda function implementing this custom resource provider. This parameter is required.
      Returns:
      this
      See Also:
    • removalPolicy

      @Stability(Stable) public AwsCustomResource.Builder removalPolicy(RemovalPolicy removalPolicy)
      The policy to apply when this resource is removed from the application.

      Default: cdk.RemovalPolicy.Destroy

      Parameters:
      removalPolicy - The policy to apply when this resource is removed from the application. This parameter is required.
      Returns:
      this
    • resourceType

      @Stability(Stable) public AwsCustomResource.Builder resourceType(String resourceType)
      Cloudformation Resource type.

      Default: - Custom::AWS

      Parameters:
      resourceType - Cloudformation Resource type. This parameter is required.
      Returns:
      this
    • role

      @Stability(Stable) public AwsCustomResource.Builder role(IRole role)
      The execution role for the singleton Lambda function implementing this custom resource provider.

      This role will apply to all AwsCustomResource instances in the stack. The role must be assumable by the lambda.amazonaws.com service principal.

      Default: - a new role is created

      Parameters:
      role - The execution role for the singleton Lambda function implementing this custom resource provider. This parameter is required.
      Returns:
      this
    • timeout

      @Stability(Stable) public AwsCustomResource.Builder timeout(Duration timeout)
      The timeout for the singleton Lambda function implementing this custom resource.

      Default: Duration.minutes(2)

      Parameters:
      timeout - The timeout for the singleton Lambda function implementing this custom resource. This parameter is required.
      Returns:
      this
    • vpc

      @Stability(Stable) public AwsCustomResource.Builder vpc(IVpc vpc)
      The vpc to provision the lambda function in.

      Default: - the function is not provisioned inside a vpc.

      Parameters:
      vpc - The vpc to provision the lambda function in. This parameter is required.
      Returns:
      this
    • vpcSubnets

      @Stability(Stable) public AwsCustomResource.Builder vpcSubnets(SubnetSelection vpcSubnets)
      Which subnets from the VPC to place the lambda function in.

      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 - Which subnets from the VPC to place the lambda function in. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public AwsCustomResource build()
      Specified by:
      build in interface software.amazon.jsii.Builder<AwsCustomResource>
      Returns:
      a newly built instance of AwsCustomResource.