CustomResource

class aws_cdk.aws_cloudformation.CustomResource(scope, id, *, properties=None, provider, removal_policy=None, resource_type=None)

Bases: aws_cdk.core.CustomResource

(deprecated) Deprecated.

Deprecated

use core.CustomResource

Stability

deprecated

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 is of type CustomResourceProvider
# properties is of type object

custom_resource = cloudformation.CustomResource(self, "MyCustomResource",
    provider=custom_resource_provider,

    # the properties below are optional
    properties={
        "properties_key": properties
    },
    removal_policy=cdk.RemovalPolicy.DESTROY,
    resource_type="resourceType"
)
Parameters
  • scope (Construct) –

  • id (str) –

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

  • 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:: // use the provider framework from aws-cdk/custom-resources: provider: new custom_resources.Provider({ onEventHandler: myOnEventLambda, isCompleteHandler: myIsCompleteLambda, // optional }); Example:: // invoke an AWS Lambda function when a lifecycle event occurs: provider: CustomResourceProvider.fromLambda(myFunction) Example:: // publish lifecycle events to an SNS topic: provider: CustomResourceProvider.fromTopic(myTopic)

  • 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

Stability

deprecated

Methods

apply_removal_policy(policy)

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

Parameters

policy (RemovalPolicy) –

Return type

None

get_att(attribute_name)

Returns the value of an attribute of the custom resource of an arbitrary type.

Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

Parameters

attribute_name (str) – the name of the attribute.

Return type

Reference

Returns

a token for Fn::GetAtt. Use Token.asXxx to encode the returned Reference as a specific type or use the convenience getAttString for string attributes.

get_att_string(attribute_name)

Returns the value of an attribute of the custom resource of type string.

Attributes are returned from the custom resource provider through the Data map where the key is the attribute name.

Parameters

attribute_name (str) – the name of the attribute.

Return type

str

Returns

a token for Fn::GetAtt encoded as a string.

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

Return type

ResourceEnvironment

node

The construct tree node associated with this construct.

Return type

ConstructNode

ref

The physical name of this custom resource.

Return type

str

stack

The stack in which this resource is defined.

Return type

Stack

Static Methods

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool

classmethod is_resource(construct)

Check whether the given construct is a Resource.

Parameters

construct (IConstruct) –

Return type

bool