1 | import { Construct } from 'constructs';
|
2 | import { RemovalPolicy } from './removal-policy';
|
3 | import { Resource } from './resource';
|
4 | /**
|
5 | * Properties to provide a Lambda-backed custom resource
|
6 | */
|
7 | export interface CustomResourceProps {
|
8 | /**
|
9 | * The ARN of the provider which implements this custom resource type.
|
10 | *
|
11 | * You can implement a provider by listening to raw AWS CloudFormation events
|
12 | * and specify the ARN of an SNS topic (`topic.topicArn`) or the ARN of an AWS
|
13 | * Lambda function (`lambda.functionArn`) or use the CDK's custom [resource
|
14 | * provider framework] which makes it easier to implement robust providers.
|
15 | *
|
16 | * [resource provider framework]:
|
17 | * https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html
|
18 | *
|
19 | * Provider framework:
|
20 | *
|
21 | * ```ts
|
22 | * // use the provider framework from aws-cdk/custom-resources:
|
23 | * const provider = new customresources.Provider(this, 'ResourceProvider', {
|
24 | * onEventHandler,
|
25 | * isCompleteHandler, // optional
|
26 | * });
|
27 | *
|
28 | * new CustomResource(this, 'MyResource', {
|
29 | * serviceToken: provider.serviceToken,
|
30 | * });
|
31 | * ```
|
32 | *
|
33 | * AWS Lambda function:
|
34 | *
|
35 | * ```ts
|
36 | * // invoke an AWS Lambda function when a lifecycle event occurs:
|
37 | * new CustomResource(this, 'MyResource', {
|
38 | * serviceToken: myFunction.functionArn,
|
39 | * });
|
40 | * ```
|
41 | *
|
42 | * SNS topic:
|
43 | *
|
44 | * ```ts
|
45 | * // publish lifecycle events to an SNS topic:
|
46 | * new CustomResource(this, 'MyResource', {
|
47 | * serviceToken: myTopic.topicArn,
|
48 | * });
|
49 | * ```
|
50 | */
|
51 | readonly serviceToken: string;
|
52 | /**
|
53 | * Properties to pass to the Lambda
|
54 | *
|
55 | * @default - No properties.
|
56 | */
|
57 | readonly properties?: {
|
58 | [key: string]: any;
|
59 | };
|
60 | /**
|
61 | * For custom resources, you can specify AWS::CloudFormation::CustomResource
|
62 | * (the default) as the resource type, or you can specify your own resource
|
63 | * type name. For example, you can use "Custom::MyCustomResourceTypeName".
|
64 | *
|
65 | * Custom resource type names must begin with "Custom::" and can include
|
66 | * alphanumeric characters and the following characters: _@-. You can specify
|
67 | * a custom resource type name up to a maximum length of 60 characters. You
|
68 | * cannot change the type during an update.
|
69 | *
|
70 | * Using your own resource type names helps you quickly differentiate the
|
71 | * types of custom resources in your stack. For example, if you had two custom
|
72 | * resources that conduct two different ping tests, you could name their type
|
73 | * as Custom::PingTester to make them easily identifiable as ping testers
|
74 | * (instead of using AWS::CloudFormation::CustomResource).
|
75 | *
|
76 | * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html#aws-cfn-resource-type-name
|
77 | *
|
78 | * @default - AWS::CloudFormation::CustomResource
|
79 | */
|
80 | readonly resourceType?: string;
|
81 | /**
|
82 | * The policy to apply when this resource is removed from the application.
|
83 | *
|
84 | * @default cdk.RemovalPolicy.Destroy
|
85 | */
|
86 | readonly removalPolicy?: RemovalPolicy;
|
87 | /**
|
88 | * Convert all property keys to pascal case.
|
89 | *
|
90 | * @default false
|
91 | */
|
92 | readonly pascalCaseProperties?: boolean;
|
93 | }
|
94 | /**
|
95 | * Instantiation of a custom resource, whose implementation is provided a Provider
|
96 | *
|
97 | * This class is intended to be used by construct library authors. Application
|
98 | * builder should not be able to tell whether or not a construct is backed by
|
99 | * a custom resource, and so the use of this class should be invisible.
|
100 | *
|
101 | * Instead, construct library authors declare a custom construct that hides the
|
102 | * choice of provider, and accepts a strongly-typed properties object with the
|
103 | * properties your provider accepts.
|
104 | *
|
105 | * Your custom resource provider (identified by the `serviceToken` property)
|
106 | * can be one of 4 constructs:
|
107 | *
|
108 | * - If you are authoring a construct library or application, we recommend you
|
109 | * use the `Provider` class in the `custom-resources` module.
|
110 | * - If you are authoring a construct for the CDK's AWS Construct Library,
|
111 | * you should use the `CustomResourceProvider` construct in this package.
|
112 | * - If you want full control over the provider, you can always directly use
|
113 | * a Lambda Function or SNS Topic by passing the ARN into `serviceToken`.
|
114 | *
|
115 | * @resource AWS::CloudFormation::CustomResource
|
116 | */
|
117 | export declare class CustomResource extends Resource {
|
118 | private readonly resource;
|
119 | constructor(scope: Construct, id: string, props: CustomResourceProps);
|
120 | /**
|
121 | * The physical name of this custom resource.
|
122 | */
|
123 | get ref(): string;
|
124 | /**
|
125 | * Returns the value of an attribute of the custom resource of an arbitrary
|
126 | * type. Attributes are returned from the custom resource provider through the
|
127 | * `Data` map where the key is the attribute name.
|
128 | *
|
129 | * @param attributeName the name of the attribute
|
130 | * @returns a token for `Fn::GetAtt`. Use `Token.asXxx` to encode the returned `Reference` as a specific type or
|
131 | * use the convenience `getAttString` for string attributes.
|
132 | */
|
133 | getAtt(attributeName: string): import("./reference").Reference;
|
134 | /**
|
135 | * Returns the value of an attribute of the custom resource of type string.
|
136 | * Attributes are returned from the custom resource provider through the
|
137 | * `Data` map where the key is the attribute name.
|
138 | *
|
139 | * @param attributeName the name of the attribute
|
140 | * @returns a token for `Fn::GetAtt` encoded as a string.
|
141 | */
|
142 | getAttString(attributeName: string): string;
|
143 | }
|