Class CustomResourceProvider

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

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:55.009Z") @Stability(Stable) public class CustomResourceProvider extends Construct
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.

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_14_X)
         .build());
 String roleArn = provider.getRoleArn();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.constructs.Construct

    software.constructs.Construct.Builder

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct

    IConstruct.Jsii$Default, IConstruct.Jsii$Proxy

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef)
     
    protected
    CustomResourceProvider(software.constructs.Construct scope, String id, CustomResourceProviderProps props)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    The hash of the lambda code backing this provider.
    static String
    getOrCreate(software.constructs.Construct scope, String uniqueid, CustomResourceProviderProps props)
    Returns a stack-level singleton ARN (service token) for the custom resource provider.
    getOrCreateProvider(software.constructs.Construct scope, String uniqueid, CustomResourceProviderProps props)
    Returns a stack-level singleton for the custom resource provider.
    The ARN of the provider's AWS Lambda function role.
    The ARN of the provider's AWS Lambda function which should be used as the serviceToken when defining a custom resource.

    Methods inherited from class software.amazon.awscdk.core.Construct

    getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate

    Methods inherited from class software.constructs.Construct

    toString

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • 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.
    • getCodeHash

      @Stability(Stable) @NotNull public String getCodeHash()
      The hash of the lambda code backing this provider.

      Can be used to trigger updates on code changes, even when the properties of a custom resource remain unchanged.

    • getRoleArn

      @Stability(Stable) @NotNull public String getRoleArn()
      The ARN of the provider's AWS Lambda function role.
    • getServiceToken

      @Stability(Stable) @NotNull public String getServiceToken()
      The ARN of the provider's AWS Lambda function which should be used as the serviceToken when defining a custom resource.

      Example:

       CustomResourceProvider myProvider;
       CustomResource.Builder.create(this, "MyCustomResource")
               .serviceToken(myProvider.getServiceToken())
               .properties(Map.of(
                       "myPropertyOne", "one",
                       "myPropertyTwo", "two"))
               .build();