Class CustomResourceProvider
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
,software.constructs.IConstruct
,software.constructs.IDependable
This is a provider for CustomResource
constructs, backed by an AWS Lambda
Function. It only supports NodeJS runtimes.
Application builders do not need to use this provider type. 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 theiam
library already depends on the CDKcore
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_18_X) .build()); provider.addToRolePolicy(Map.of( "Effect", "Allow", "Action", "s3:GetObject", "Resource", "*"));
-
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
-
Constructor Summary
ModifierConstructorDescriptionprotected
CustomResourceProvider
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CustomResourceProvider
(software.amazon.jsii.JsiiObjectRef objRef) protected
CustomResourceProvider
(software.constructs.Construct scope, String id, CustomResourceProviderProps props) -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getOrCreate
(software.constructs.Construct scope, String uniqueid, CustomResourceProviderProps props) Returns a stack-level singleton ARN (service token) for the custom resource provider.static CustomResourceProvider
getOrCreateProvider
(software.constructs.Construct scope, String uniqueid, CustomResourceProviderProps props) Returns a stack-level singleton for the custom resource provider.Methods inherited from class software.amazon.awscdk.CustomResourceProviderBase
addToRolePolicy, getCodeHash, getRoleArn, getServiceToken
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.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CustomResourceProvider
protected CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef) -
CustomResourceProvider
protected CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
CustomResourceProvider
@Stability(Stable) protected CustomResourceProvider(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull CustomResourceProviderProps props) - Parameters:
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.
-
-
Method Details
-
getOrCreate
@Stability(Stable) @NotNull public static String getOrCreate(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull CustomResourceProviderProps props) Returns a stack-level singleton ARN (service token) for the custom resource provider.- Parameters:
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.- Returns:
- the service token of the custom resource provider, which should be
used when defining a
CustomResource
.
-
getOrCreateProvider
@Stability(Stable) @NotNull public static CustomResourceProvider getOrCreateProvider(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull CustomResourceProviderProps props) Returns a stack-level singleton for the custom resource provider.- Parameters:
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.- Returns:
- the service token of the custom resource provider, which should be
used when defining a
CustomResource
.
-