Class CustomResource
- All Implemented Interfaces:
IConstruct,IDependable,IResource,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct
- Direct Known Subclasses:
CustomResource
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
Providerclass in thecustom-resourcesmodule. - If you are authoring a construct for the CDK's AWS Construct Library,
you should use the
CustomResourceProviderconstruct 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_14_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 ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.core.IConstruct
IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.core.IResource
IResource.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCustomResource(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCustomResource(software.amazon.jsii.JsiiObjectRef objRef) CustomResource(software.constructs.Construct scope, String id, CustomResourceProps props) -
Method Summary
Modifier and TypeMethodDescriptionReturns 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.getRef()The physical name of this custom resource.Methods inherited from class software.amazon.awscdk.core.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isResourceMethods inherited from class software.amazon.awscdk.core.Construct
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validateMethods inherited from class software.constructs.Construct
toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awscdk.core.IConstruct
getNodeMethods 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
Returns the value of an attribute of the custom resource of an arbitrary type.Attributes are returned from the custom resource provider through the
Datamap where the key is the attribute name.- Parameters:
attributeName- the name of the attribute. This parameter is required.- Returns:
- a token for
Fn::GetAtt. UseToken.asXxxto encode the returnedReferenceas a specific type or use the conveniencegetAttStringfor string attributes.
-
getAttString
Returns the value of an attribute of the custom resource of type string.Attributes are returned from the custom resource provider through the
Datamap where the key is the attribute name.- Parameters:
attributeName- the name of the attribute. This parameter is required.- Returns:
- a token for
Fn::GetAttencoded as a string.
-
getRef
The physical name of this custom resource.
-