@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:35.884Z") @Stability(value=Stable) public class CustomResourceProvider extends software.constructs.Construct
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.PolicyStatementobjects, since theiamlibrary already depends on the CDKcorelibrary 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:
// Example automatically generated from non-compiling source. May contain errors.
CustomResourceProvider provider = CustomResourceProvider.getOrCreateProvider(this, "Custom::MyCustomResourceType", CustomResourceProviderProps.builder()
.codeDirectory(String.format("%s/my-handler", __dirname))
.runtime(CustomResourceProviderRuntime.NODEJS_14_X)
.build());
provider.addToRolePolicy(Map.of(
"Effect", "Allow",
"Action", "s3:GetObject",
"Resource", "*"));
| Modifier | Constructor and Description |
|---|---|
protected |
CustomResourceProvider(software.constructs.Construct scope,
String id,
CustomResourceProviderProps props) |
protected |
CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addToRolePolicy(Object statement)
Add an IAM policy statement to the inline policy of the provider's lambda function's role.
|
static 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.
|
String |
getRoleArn()
The ARN of the provider's AWS Lambda function role.
|
String |
getServiceToken()
The ARN of the provider's AWS Lambda function which should be used as the `serviceToken` when defining a custom resource.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected CustomResourceProvider(software.amazon.jsii.JsiiObjectRef objRef)
protected CustomResourceProvider(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
protected CustomResourceProvider(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
CustomResourceProviderProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable) @NotNull public static String getOrCreate(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull 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.@Stability(value=Stable) @NotNull public static CustomResourceProvider getOrCreateProvider(@NotNull software.constructs.Construct scope, @NotNull String uniqueid, @NotNull 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.@Stability(value=Stable)
public void addToRolePolicy(@NotNull
Object statement)
Please note: this is a direct IAM JSON policy blob, not a iam.PolicyStatement
object like you will see in the rest of the CDK.
Example:
// Example automatically generated from non-compiling source. May contain errors.
CustomResourceProvider myProvider;
myProvider.addToRolePolicy(Map.of(
"Effect", "Allow",
"Action", "s3:GetObject",
"Resource", "*"));
statement - This parameter is required.@Stability(value=Stable) @NotNull public String getRoleArn()
@Stability(value=Stable) @NotNull public String getServiceToken()
Example:
// Example automatically generated from non-compiling source. May contain errors.
CustomResourceProvider myProvider;
CustomResource.Builder.create(this, "MyCustomResource")
.serviceToken(myProvider.getServiceToken())
.properties(Map.of(
"myPropertyOne", "one",
"myPropertyTwo", "two"))
.build();
Copyright © 2022. All rights reserved.