Class CustomResource
- All Implemented Interfaces:
IEnvironmentAware,IResource,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
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:
Stack stack = new Stack();
CfnParameter durToken = CfnParameter.Builder.create(stack, "MyParameter")
.type("Number")
.default(60)
.build();
CustomResource.Builder.create(stack, "MyCustomResource")
.serviceToken("MyServiceToken")
.serviceTimeout(Duration.seconds(durToken.getValueAsNumber()))
.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.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$Default -
Field Summary
Fields -
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.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, 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.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Field Details
-
PROPERTY_INJECTION_ID
Uniquely identifies this class.
-
-
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.
-