Class CustomResourceProvider

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.CustomResourceProviderBase
software.amazon.awscdk.CustomResourceProvider
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:23:55.773Z") @Stability(Stable) public class CustomResourceProvider extends CustomResourceProviderBase
An AWS-Lambda backed custom resource provider, for CDK Construct Library constructs.

This is a provider for CustomResource constructs, backed by an AWS Lambda Function. It only supports NodeJS runtimes.

Application builders do not need to use this provider type. This is not a generic custom resource provider class. It is specifically intended to be used only by constructs in the AWS CDK Construct Library, and only exists here because of reverse dependency issues (for example, it cannot use iam.PolicyStatement objects, since the iam library already depends on the CDK core library and we cannot have cyclic dependencies).

If you are not writing constructs for the AWS Construct Library, you should use the Provider class in the custom-resources module instead, which has a better API and supports all Lambda runtimes, not just Node.

N.B.: When you are writing Custom Resource Providers, there are a number of lifecycle events you have to pay attention to. These are documented in the README of the custom-resources module. Be sure to give the documentation in that module a read, regardless of whether you end up using the Provider class in there or this one.

Example:

 CustomResourceProvider provider = CustomResourceProvider.getOrCreateProvider(this, "Custom::MyCustomResourceType", CustomResourceProviderProps.builder()
         .codeDirectory(String.format("%s/my-handler", __dirname))
         .runtime(CustomResourceProviderRuntime.NODEJS_18_X)
         .build());
 provider.addToRolePolicy(Map.of(
         "Effect", "Allow",
         "Action", "s3:GetObject",
         "Resource", "*"));
 
  • Constructor Details

    • CustomResourceProvider

      protected CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef)
    • CustomResourceProvider

      protected CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • CustomResourceProvider

      @Stability(Stable) protected CustomResourceProvider(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CustomResourceProviderProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • getOrCreate

      @Stability(Stable) @NotNull public static String getOrCreate(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull CustomResourceProviderProps props)
      Returns a stack-level singleton ARN (service token) for the custom resource provider.

      Parameters:
      scope - Construct scope. This parameter is required.
      uniqueid - A globally unique id that will be used for the stack-level construct. This parameter is required.
      props - Provider properties which will only be applied when the provider is first created. This parameter is required.
      Returns:
      the service token of the custom resource provider, which should be used when defining a CustomResource.
    • getOrCreateProvider

      @Stability(Stable) @NotNull public static CustomResourceProvider getOrCreateProvider(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull CustomResourceProviderProps props)
      Returns a stack-level singleton for the custom resource provider.

      Parameters:
      scope - Construct scope. This parameter is required.
      uniqueid - A globally unique id that will be used for the stack-level construct. This parameter is required.
      props - Provider properties which will only be applied when the provider is first created. This parameter is required.
      Returns:
      the service token of the custom resource provider, which should be used when defining a CustomResource.