Class CustomResource
Instantiation of a custom resource, whose implementation is provided a Provider.
public class CustomResource : Resource, IResource, IConstruct, IConstruct, IDependable
- Inheritance
-
CustomResource
- Implements
-
IConstruct
- Inherited Members
Examples
var serviceToken = CustomResourceProvider.GetOrCreate(this, "Custom::MyCustomResourceType", new CustomResourceProviderProps {
CodeDirectory = $"{__dirname}/my-handler",
Runtime = CustomResourceProviderRuntime.NODEJS_14_X,
Description = "Lambda function created by the custom resource provider"
});
new CustomResource(this, "MyResource", new CustomResourceProps {
ResourceType = "Custom::MyCustomResourceType",
ServiceToken = serviceToken
});
Remarks
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:
Resource: AWS::CloudFormation::CustomResource
ExampleMetadata: infused
Constructors
CustomResource(Construct, string, ICustomResourceProps)
public CustomResource(Construct scope, string id, ICustomResourceProps props)
Parameters
scope
Constructid
stringprops
ICustomResourceProps
Properties
Ref
The physical name of this custom resource.
public virtual string Ref { get; }
Property Value
Methods
GetAtt(string)
Returns the value of an attribute of the custom resource of an arbitrary type.
public virtual Reference GetAtt(string attributeName)
Parameters
attributeName
stringthe name of the attribute.
Returns
- Reference
a token for
Fn::GetAtt
. UseToken.asXxx
to encode the returnedReference
as a specific type or use the conveniencegetAttString
for string attributes.
Remarks
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.
GetAttString(string)
Returns the value of an attribute of the custom resource of type string.
public virtual string GetAttString(string attributeName)
Parameters
attributeName
stringthe name of the attribute.
Returns
- string
a token for
Fn::GetAtt
encoded as a string.
Remarks
Attributes are returned from the custom resource provider through the
Data
map where the key is the attribute name.