public static final class CustomResource.Builder
extends java.lang.Object
CustomResource
.Modifier and Type | Method and Description |
---|---|
CustomResource |
build() |
static CustomResource.Builder |
create(software.constructs.Construct scope,
java.lang.String id) |
CustomResource.Builder |
pascalCaseProperties(java.lang.Boolean pascalCaseProperties)
Convert all property keys to pascal case.
|
CustomResource.Builder |
properties(java.util.Map<java.lang.String,? extends java.lang.Object> properties)
Properties to pass to the Lambda.
|
CustomResource.Builder |
removalPolicy(RemovalPolicy removalPolicy)
The policy to apply when this resource is removed from the application.
|
CustomResource.Builder |
resourceType(java.lang.String resourceType)
For custom resources, you can specify AWS::CloudFormation::CustomResource (the default) as the resource type, or you can specify your own resource type name.
|
CustomResource.Builder |
serviceToken(java.lang.String serviceToken)
The ARN of the provider which implements this custom resource type.
|
public static CustomResource.Builder create(software.constructs.Construct scope, java.lang.String id)
scope
- This parameter is required.id
- This parameter is required.CustomResource.Builder
.public CustomResource.Builder serviceToken(java.lang.String serviceToken)
You can implement a provider by listening to raw AWS CloudFormation events
and specify the ARN of an SNS topic (topic.topicArn
) or the ARN of an AWS
Lambda function (lambda.functionArn
) or use the CDK's custom resource
provider framework which makes it easier to implement robust providers.
Provider framework:
// use the provider framework from aws-cdk/custom-resources: Provider provider = Provider.Builder.create(this, "ResourceProvider") .onEventHandler(onEventHandler) .isCompleteHandler(isCompleteHandler) .build(); CustomResource.Builder.create(this, "MyResource") .serviceToken(provider.getServiceToken()) .build();
AWS Lambda function:
// invoke an AWS Lambda function when a lifecycle event occurs: // invoke an AWS Lambda function when a lifecycle event occurs: CustomResource.Builder.create(this, "MyResource") .serviceToken(myFunction.getFunctionArn()) .build();
SNS topic:
// publish lifecycle events to an SNS topic: // publish lifecycle events to an SNS topic: CustomResource.Builder.create(this, "MyResource") .serviceToken(myTopic.getTopicArn()) .build();
serviceToken
- The ARN of the provider which implements this custom resource type. This parameter is required.this
public CustomResource.Builder pascalCaseProperties(java.lang.Boolean pascalCaseProperties)
Default: false
pascalCaseProperties
- Convert all property keys to pascal case. This parameter is required.this
public CustomResource.Builder properties(java.util.Map<java.lang.String,? extends java.lang.Object> properties)
Default: - No properties.
properties
- Properties to pass to the Lambda. This parameter is required.this
public CustomResource.Builder removalPolicy(RemovalPolicy removalPolicy)
Default: cdk.RemovalPolicy.Destroy
removalPolicy
- The policy to apply when this resource is removed from the application. This parameter is required.this
public CustomResource.Builder resourceType(java.lang.String resourceType)
For example, you can use "Custom::MyCustomResourceTypeName".
Custom resource type names must begin with "Custom::" and can include alphanumeric characters and the following characters: _@-. You can specify a custom resource type name up to a maximum length of 60 characters. You cannot change the type during an update.
Using your own resource type names helps you quickly differentiate the types of custom resources in your stack. For example, if you had two custom resources that conduct two different ping tests, you could name their type as Custom::PingTester to make them easily identifiable as ping testers (instead of using AWS::CloudFormation::CustomResource).
Default: - AWS::CloudFormation::CustomResource
resourceType
- For custom resources, you can specify AWS::CloudFormation::CustomResource (the default) as the resource type, or you can specify your own resource type name. This parameter is required.this
public CustomResource build()