Show / Hide Table of Contents

Interface ICustomResourceProps

Properties to provide a Lambda-backed custom resource.

Namespace: Amazon.CDK
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public interface ICustomResourceProps
Syntax (vb)
Public Interface ICustomResourceProps
Remarks

ExampleMetadata: infused

Examples
var stack = new Stack();
            var durToken = new CfnParameter(stack, "MyParameter", new CfnParameterProps {
                Type = "Number",
                Default = 60
            });
            new CustomResource(stack, "MyCustomResource", new CustomResourceProps {
                ServiceToken = "MyServiceToken",
                ServiceTimeout = Duration.Seconds(durToken.ValueAsNumber)
            });

Synopsis

Properties

PascalCaseProperties

Convert all property keys to pascal case.

Properties

Properties to pass to the Lambda.

RemovalPolicy

The policy to apply when this resource is removed from the application.

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.

ServiceTimeout

The maximum time that can elapse before a custom resource operation times out.

ServiceToken

The ARN of the provider which implements this custom resource type.

Properties

PascalCaseProperties

Convert all property keys to pascal case.

bool? PascalCaseProperties { get; }
Property Value

bool?

Remarks

Default: false

Properties

Properties to pass to the Lambda.

IDictionary<string, object>? Properties { get; }
Property Value

IDictionary<string, object>

Remarks

Values in this properties dictionary can possibly overwrite other values in CustomResourceProps E.g. ServiceToken and ServiceTimeout It is recommended to avoid using same keys that exist in CustomResourceProps

Default: - No properties.

RemovalPolicy

The policy to apply when this resource is removed from the application.

RemovalPolicy? RemovalPolicy { get; }
Property Value

RemovalPolicy?

Remarks

Default: cdk.RemovalPolicy.Destroy

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.

string? ResourceType { get; }
Property Value

string

Remarks

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

See: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html#aws-cfn-resource-type-name

ServiceTimeout

The maximum time that can elapse before a custom resource operation times out.

Duration? ServiceTimeout { get; }
Property Value

Duration

Remarks

The value must be between 1 second and 3600 seconds.

Maps to ServiceTimeout property for the AWS::CloudFormation::CustomResource resource

A token can be specified for this property, but it must be specified with Duration.seconds().

Default: Duration.seconds(3600)

Examples
var stack = new Stack();
             var durToken = new CfnParameter(stack, "MyParameter", new CfnParameterProps {
                 Type = "Number",
                 Default = 60
             });
             new CustomResource(stack, "MyCustomResource", new CustomResourceProps {
                 ServiceToken = "MyServiceToken",
                 ServiceTimeout = Duration.Seconds(durToken.ValueAsNumber)
             });

ServiceToken

The ARN of the provider which implements this custom resource type.

string ServiceToken { get; }
Property Value

string

Remarks

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:
var provider = new Provider(this, "ResourceProvider", new ProviderProps {
    OnEventHandler = onEventHandler,
    IsCompleteHandler = isCompleteHandler
});

new CustomResource(this, "MyResource", new CustomResourceProps {
    ServiceToken = provider.ServiceToken
});

AWS Lambda function (not recommended to use AWS Lambda Functions directly, see the module README):

// invoke an AWS Lambda function when a lifecycle event occurs:
// invoke an AWS Lambda function when a lifecycle event occurs:
new CustomResource(this, "MyResource", new CustomResourceProps {
    ServiceToken = myFunction.FunctionArn
});

SNS topic (not recommended to use AWS Lambda Functions directly, see the module README):

// publish lifecycle events to an SNS topic:
// publish lifecycle events to an SNS topic:
new CustomResource(this, "MyResource", new CustomResourceProps {
    ServiceToken = myTopic.TopicArn
});

Maps to ServiceToken property for the AWS::CloudFormation::CustomResource resource

Back to top Generated by DocFX