Class CustomResourceProvider
An AWS-Lambda backed custom resource provider, for CDK Construct Library constructs.
Inherited Members
Namespace: Amazon.CDK
Assembly: Amazon.CDK.dll
Syntax (csharp)
public class CustomResourceProvider : Construct, IConstruct, IDependable
Syntax (vb)
Public Class CustomResourceProvider
Inherits Construct
Implements IConstruct, IDependable
Remarks
This is a provider for CustomResource
constructs, backed by an AWS Lambda
Function. It only supports NodeJS runtimes.
This is not a generic custom resource provider class. It is specifically
intended to be used only by constructs in the AWS CDK Construct Library, and
only exists here because of reverse dependency issues (for example, it cannot
use iam.PolicyStatement
objects, since the iam
library already depends on
the CDK core
library and we cannot have cyclic dependencies).
If you are not writing constructs for the AWS Construct Library, you should
use the Provider
class in the custom-resources
module instead, which has
a better API and supports all Lambda runtimes, not just Node.
N.B.: When you are writing Custom Resource Providers, there are a number of
lifecycle events you have to pay attention to. These are documented in the
README of the custom-resources
module. Be sure to give the documentation
in that module a read, regardless of whether you end up using the Provider
class in there or this one.
ExampleMetadata: infused
Examples
var provider = CustomResourceProvider.GetOrCreateProvider(this, "Custom::MyCustomResourceType", new CustomResourceProviderProps {
CodeDirectory = $"{__dirname}/my-handler",
Runtime = CustomResourceProviderRuntime.NODEJS_14_X
});
var roleArn = provider.RoleArn;
Synopsis
Constructors
CustomResourceProvider(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CustomResourceProvider(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
CustomResourceProvider(Construct, String, ICustomResourceProviderProps) |
Properties
CodeHash | The hash of the lambda code backing this provider. |
RoleArn | The ARN of the provider's AWS Lambda function role. |
ServiceToken | The ARN of the provider's AWS Lambda function which should be used as the |
Methods
GetOrCreate(Construct, String, ICustomResourceProviderProps) | Returns a stack-level singleton ARN (service token) for the custom resource provider. |
GetOrCreateProvider(Construct, String, ICustomResourceProviderProps) | Returns a stack-level singleton for the custom resource provider. |
Constructors
CustomResourceProvider(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CustomResourceProvider(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CustomResourceProvider(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CustomResourceProvider(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
CustomResourceProvider(Construct, String, ICustomResourceProviderProps)
public CustomResourceProvider(Construct scope, string id, ICustomResourceProviderProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props ICustomResourceProviderProps
Properties
CodeHash
The hash of the lambda code backing this provider.
public virtual string CodeHash { get; }
Property Value
System.String
Remarks
Can be used to trigger updates on code changes, even when the properties of a custom resource remain unchanged.
RoleArn
The ARN of the provider's AWS Lambda function role.
public virtual string RoleArn { get; }
Property Value
System.String
ServiceToken
The ARN of the provider's AWS Lambda function which should be used as the serviceToken
when defining a custom resource.
public virtual string ServiceToken { get; }
Property Value
System.String
Examples
CustomResourceProvider myProvider;
new CustomResource(this, "MyCustomResource", new CustomResourceProps {
ServiceToken = myProvider.ServiceToken,
Properties = new Dictionary<string, object> {
{ "myPropertyOne", "one" },
{ "myPropertyTwo", "two" }
}
});
Methods
GetOrCreate(Construct, String, ICustomResourceProviderProps)
Returns a stack-level singleton ARN (service token) for the custom resource provider.
public static string GetOrCreate(Construct scope, string uniqueid, ICustomResourceProviderProps props)
Parameters
- scope Constructs.Construct
Construct scope.
- uniqueid System.String
A globally unique id that will be used for the stack-level construct.
- props ICustomResourceProviderProps
Provider properties which will only be applied when the provider is first created.
Returns
System.String
the service token of the custom resource provider, which should be
used when defining a CustomResource
.
GetOrCreateProvider(Construct, String, ICustomResourceProviderProps)
Returns a stack-level singleton for the custom resource provider.
public static CustomResourceProvider GetOrCreateProvider(Construct scope, string uniqueid, ICustomResourceProviderProps props)
Parameters
- scope Constructs.Construct
Construct scope.
- uniqueid System.String
A globally unique id that will be used for the stack-level construct.
- props ICustomResourceProviderProps
Provider properties which will only be applied when the provider is first created.
Returns
the service token of the custom resource provider, which should be
used when defining a CustomResource
.