@Generated(value="jsii-pacmak/1.74.0 (build 6d08790)", date="2023-03-22T19:35:34.967Z") public class CustomResourceProvider extends Construct
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.
Example:
CustomResourceProvider provider = CustomResourceProvider.getOrCreateProvider(this, "Custom::MyCustomResourceType", CustomResourceProviderProps.builder() .codeDirectory(String.format("%s/my-handler", __dirname)) .runtime(CustomResourceProviderRuntime.NODEJS_14_X) .build()); String roleArn = provider.getRoleArn();
IConstruct.Jsii$Default, IConstruct.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef) |
protected |
CustomResourceProvider(software.constructs.Construct scope,
java.lang.String id,
CustomResourceProviderProps props) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCodeHash()
The hash of the lambda code backing this provider.
|
static java.lang.String |
getOrCreate(software.constructs.Construct scope,
java.lang.String uniqueid,
CustomResourceProviderProps props)
Returns a stack-level singleton ARN (service token) for the custom resource provider.
|
static CustomResourceProvider |
getOrCreateProvider(software.constructs.Construct scope,
java.lang.String uniqueid,
CustomResourceProviderProps props)
Returns a stack-level singleton for the custom resource provider.
|
java.lang.String |
getRoleArn()
The ARN of the provider's AWS Lambda function role.
|
java.lang.String |
getServiceToken()
The ARN of the provider's AWS Lambda function which should be used as the `serviceToken` when defining a custom resource.
|
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
protected CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef)
protected CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
protected CustomResourceProvider(software.constructs.Construct scope, java.lang.String id, CustomResourceProviderProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public static java.lang.String getOrCreate(software.constructs.Construct scope, java.lang.String uniqueid, CustomResourceProviderProps props)
scope
- Construct scope. This parameter is required.uniqueid
- A globally unique id that will be used for the stack-level construct. This parameter is required.props
- Provider properties which will only be applied when the provider is first created. This parameter is required.public static CustomResourceProvider getOrCreateProvider(software.constructs.Construct scope, java.lang.String uniqueid, CustomResourceProviderProps props)
scope
- Construct scope. This parameter is required.uniqueid
- A globally unique id that will be used for the stack-level construct. This parameter is required.props
- Provider properties which will only be applied when the provider is first created. This parameter is required.public java.lang.String getCodeHash()
Can be used to trigger updates on code changes, even when the properties of a custom resource remain unchanged.
public java.lang.String getRoleArn()
public java.lang.String getServiceToken()
Example:
CustomResourceProvider myProvider; CustomResource.Builder.create(this, "MyCustomResource") .serviceToken(myProvider.getServiceToken()) .properties(Map.of( "myPropertyOne", "one", "myPropertyTwo", "two")) .build();