CustomResourceProps

class aws_cdk.aws_cloudformation.CustomResourceProps(*, provider, properties=None, removal_policy=None, resource_type=None)

Bases: object

(deprecated) Properties to provide a Lambda-backed custom resource.

Parameters
  • provider (ICustomResourceProvider) – (deprecated) The provider which implements the custom resource. You can implement a provider by listening to raw AWS CloudFormation events through an SNS topic or an AWS Lambda function or use the CDK’s custom resource provider framework which makes it easier to implement robust providers:: import * as custom_resources from @aws-cdk/custom-resources’; import * as lambda from @aws-cdk/aws-lambda’; import { Stack } from @aws-cdk/core’; declare const myOnEventLambda: lambda.Function; declare const myIsCompleteLambda: lambda.Function; const stack = new Stack(); const provider = new custom_resources.Provider(stack, ‘myProvider’, { onEventHandler: myOnEventLambda, isCompleteHandler: myIsCompleteLambda, // optional }); Example:: import * as cloudformation from @aws-cdk/aws-cloudformation’; import * as lambda from @aws-cdk/aws-lambda’; declare const myFunction: lambda.Function; // invoke an AWS Lambda function when a lifecycle event occurs: const provider = cloudformation.CustomResourceProvider.fromLambda(myFunction); Example:: import * as cloudformation from @aws-cdk/aws-cloudformation’; import * as sns from @aws-cdk/aws-sns’; declare const myTopic: sns.Topic; // publish lifecycle events to an SNS topic: const provider = cloudformation.CustomResourceProvider.fromTopic(myTopic);

  • properties (Optional[Mapping[str, Any]]) – (deprecated) Properties to pass to the Lambda. Default: - No properties.

  • removal_policy (Optional[RemovalPolicy]) – (deprecated) The policy to apply when this resource is removed from the application. Default: cdk.RemovalPolicy.Destroy

  • resource_type (Optional[str]) – (deprecated) For custom resources, you can specify AWS::CloudFormation::CustomResource (the default) as the resource type, or you can specify your own resource type name. 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

Deprecated

use core.CustomResourceProps

Stability

deprecated

ExampleMetadata

fixture=_generated

Example:

# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_cloudformation as cloudformation
import aws_cdk.core as cdk

# custom_resource_provider: cloudformation.CustomResourceProvider
# properties: Any

custom_resource_props = cloudformation.CustomResourceProps(
    provider=custom_resource_provider,

    # the properties below are optional
    properties={
        "properties_key": properties
    },
    removal_policy=cdk.RemovalPolicy.DESTROY,
    resource_type="resourceType"
)

Attributes

properties

(deprecated) Properties to pass to the Lambda.

Default
  • No properties.

Stability

deprecated

Return type

Optional[Mapping[str, Any]]

provider

(deprecated) The provider which implements the custom resource.

You can implement a provider by listening to raw AWS CloudFormation events through an SNS topic or an AWS Lambda function or use the CDK’s custom resource provider framework which makes it easier to implement robust providers:

import aws_cdk.custom_resources as custom_resources
import aws_cdk.aws_lambda as lambda_
from aws_cdk.core import Stack
# my_on_event_lambda: lambda.Function
# my_is_complete_lambda: lambda.Function
stack = Stack()

provider = custom_resources.Provider(stack, "myProvider",
    on_event_handler=my_on_event_lambda,
    is_complete_handler=my_is_complete_lambda
)

Example:

import aws_cdk.aws_cloudformation as cloudformation
import aws_cdk.aws_lambda as lambda_
# my_function: lambda.Function

# invoke an AWS Lambda function when a lifecycle event occurs:
provider = cloudformation.CustomResourceProvider.from_lambda(my_function)

Example:

import aws_cdk.aws_cloudformation as cloudformation
import aws_cdk.aws_sns as sns
# my_topic: sns.Topic

# publish lifecycle events to an SNS topic:
provider = cloudformation.CustomResourceProvider.from_topic(my_topic)
Stability

deprecated

Return type

ICustomResourceProvider

removal_policy

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

Default

cdk.RemovalPolicy.Destroy

Stability

deprecated

Return type

Optional[RemovalPolicy]

resource_type

(deprecated) For custom resources, you can specify AWS::CloudFormation::CustomResource (the default) as the resource type, or you can specify your own resource type name.

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

Stability

deprecated

Return type

Optional[str]