Class CustomResource
- All Implemented Interfaces:
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
Provider
class in thecustom-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/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
ModifierConstructorDescriptionprotected
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 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, isResource
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
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
. UseToken.asXxx
to encode the returnedReference
as a specific type or use the conveniencegetAttString
for 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
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
The physical name of this custom resource.
-