Class CustomResource

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.CustomResource
All Implemented Interfaces:
IResource, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-24T02:42:32.474Z") @Stability(Stable) public class CustomResource extends Resource
Instantiation of a custom resource, whose implementation is provided a Provider.

This class is intended to be used by construct library authors. Application builder should not be able to tell whether or not a construct is backed by a custom resource, and so the use of this class should be invisible.

Instead, construct library authors declare a custom construct that hides the choice of provider, and accepts a strongly-typed properties object with the properties your provider accepts.

Your custom resource provider (identified by the serviceToken property) can be one of 4 constructs:

  • If you are authoring a construct library or application, we recommend you use the Provider class in the custom-resources module.
  • If you are authoring a construct for the CDK's AWS Construct Library, you should use the CustomResourceProvider construct in this package.
  • If you want full control over the provider, you can always directly use a Lambda Function or SNS Topic by passing the ARN into serviceToken.

Example:

 String serviceToken = CustomResourceProvider.getOrCreate(this, "Custom::MyCustomResourceType", CustomResourceProviderProps.builder()
         .codeDirectory(String.format("%s/my-handler", __dirname))
         .runtime(CustomResourceProviderRuntime.NODEJS_18_X)
         .description("Lambda function created by the custom resource provider")
         .build());
 CustomResource.Builder.create(this, "MyResource")
         .resourceType("Custom::MyCustomResourceType")
         .serviceToken(serviceToken)
         .build();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for CustomResource.

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

    software.amazon.jsii.JsiiObject.InitializationMode

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

    software.constructs.IConstruct.Jsii$Default

    Nested classes/interfaces inherited from interface software.amazon.awscdk.IResource

    IResource.Jsii$Default
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    getAtt(String attributeName)
    Returns the value of an attribute of the custom resource of an arbitrary type.
    getAttString(String attributeName)
    Returns the value of an attribute of the custom resource of type string.
    The physical name of this custom resource.

    Methods inherited from class software.constructs.Construct

    getNode, isConstruct, 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.constructs.IConstruct

    getNode

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • CustomResource

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

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

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

    • getAtt

      @Stability(Stable) @NotNull public Reference getAtt(@NotNull String attributeName)
      Returns the value of an attribute of the custom resource of an arbitrary type.

      Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

      Parameters:
      attributeName - the name of the attribute. This parameter is required.
      Returns:
      a token for Fn::GetAtt. Use Token.asXxx to encode the returned Reference as a specific type or use the convenience getAttString for string attributes.
    • getAttString

      @Stability(Stable) @NotNull public String getAttString(@NotNull String attributeName)
      Returns the value of an attribute of the custom resource of type string.

      Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

      Parameters:
      attributeName - the name of the attribute. This parameter is required.
      Returns:
      a token for Fn::GetAtt encoded as a string.
    • getRef

      @Stability(Stable) @NotNull public String getRef()
      The physical name of this custom resource.