UNPKG

5.87 kBTypeScriptView Raw
1import * as lambda from '@aws-cdk/aws-lambda';
2import * as sns from '@aws-cdk/aws-sns';
3import * as core from '@aws-cdk/core';
4import { Construct } from '@aws-cdk/core';
5/**
6 * Collection of arbitrary properties
7 *
8 * @deprecated this type has been deprecated in favor of using a key-value type directly
9 */
10export declare type Properties = {
11 [key: string]: any;
12};
13/**
14 * Configuration options for custom resource providers.
15 *
16 * @deprecated used in {@link ICustomResourceProvider} which is now deprecated
17 */
18export interface CustomResourceProviderConfig {
19 /**
20 * The ARN of the SNS topic or the AWS Lambda function which implements this
21 * provider.
22 */
23 readonly serviceToken: string;
24}
25/**
26 * Represents a provider for an AWS CloudFormation custom resources.
27 * @deprecated use `core.ICustomResourceProvider`
28 */
29export interface ICustomResourceProvider {
30 /**
31 * Called when this provider is used by a `CustomResource`.
32 * @param scope The resource that uses this provider.
33 * @returns provider configuration
34 */
35 bind(scope: Construct): CustomResourceProviderConfig;
36}
37/**
38 * Represents a provider for an AWS CloudFormation custom resources.
39 *
40 * @deprecated use core.CustomResource instead
41 */
42export declare class CustomResourceProvider implements ICustomResourceProvider {
43 readonly serviceToken: string;
44 /**
45 * The Lambda provider that implements this custom resource.
46 *
47 * We recommend using a lambda.SingletonFunction for this.
48 */
49 static fromLambda(handler: lambda.IFunction): CustomResourceProvider;
50 /**
51 * The SNS Topic for the provider that implements this custom resource.
52 */
53 static fromTopic(topic: sns.ITopic): CustomResourceProvider;
54 /**
55 * Use AWS Lambda as a provider.
56 * @deprecated use `fromLambda`
57 */
58 static lambda(handler: lambda.IFunction): CustomResourceProvider;
59 /**
60 * Use an SNS topic as the provider.
61 * @deprecated use `fromTopic`
62 */
63 static topic(topic: sns.ITopic): CustomResourceProvider;
64 /**
65 * @param serviceToken the ServiceToken which contains the ARN for this provider.
66 */
67 private constructor();
68 bind(_: Construct): CustomResourceProviderConfig;
69}
70/**
71 * Properties to provide a Lambda-backed custom resource
72 * @deprecated use `core.CustomResourceProps`
73 */
74export interface CustomResourceProps {
75 /**
76 * The provider which implements the custom resource.
77 *
78 * You can implement a provider by listening to raw AWS CloudFormation events
79 * through an SNS topic or an AWS Lambda function or use the CDK's custom
80 * [resource provider framework] which makes it easier to implement robust
81 * providers.
82 *
83 * [resource provider framework]: https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html
84 *
85 * ```ts
86 * import * as custom_resources from '@aws-cdk/custom-resources';
87 * import * as lambda from '@aws-cdk/aws-lambda';
88 * import { Stack } from '@aws-cdk/core';
89 * declare const myOnEventLambda: lambda.Function;
90 * declare const myIsCompleteLambda: lambda.Function;
91 * const stack = new Stack();
92 *
93 * const provider = new custom_resources.Provider(stack, 'myProvider', {
94 * onEventHandler: myOnEventLambda,
95 * isCompleteHandler: myIsCompleteLambda, // optional
96 * });
97 * ```
98 *
99 * ```ts
100 * import * as cloudformation from '@aws-cdk/aws-cloudformation';
101 * import * as lambda from '@aws-cdk/aws-lambda';
102 * declare const myFunction: lambda.Function;
103 *
104 * // invoke an AWS Lambda function when a lifecycle event occurs:
105 * const provider = cloudformation.CustomResourceProvider.fromLambda(myFunction);
106 * ```
107 *
108 * ```ts
109 * import * as cloudformation from '@aws-cdk/aws-cloudformation';
110 * import * as sns from '@aws-cdk/aws-sns';
111 * declare const myTopic: sns.Topic;
112 *
113 * // publish lifecycle events to an SNS topic:
114 * const provider = cloudformation.CustomResourceProvider.fromTopic(myTopic);
115 * ```
116 */
117 readonly provider: ICustomResourceProvider;
118 /**
119 * Properties to pass to the Lambda
120 *
121 * @default - No properties.
122 */
123 readonly properties?: Properties;
124 /**
125 * For custom resources, you can specify AWS::CloudFormation::CustomResource
126 * (the default) as the resource type, or you can specify your own resource
127 * type name. For example, you can use "Custom::MyCustomResourceTypeName".
128 *
129 * Custom resource type names must begin with "Custom::" and can include
130 * alphanumeric characters and the following characters: _@-. You can specify
131 * a custom resource type name up to a maximum length of 60 characters. You
132 * cannot change the type during an update.
133 *
134 * Using your own resource type names helps you quickly differentiate the
135 * types of custom resources in your stack. For example, if you had two custom
136 * resources that conduct two different ping tests, you could name their type
137 * as Custom::PingTester to make them easily identifiable as ping testers
138 * (instead of using AWS::CloudFormation::CustomResource).
139 *
140 * @see
141 * https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cfn-customresource.html#aws-cfn-resource-type-name
142 *
143 * @default - AWS::CloudFormation::CustomResource
144 */
145 readonly resourceType?: string;
146 /**
147 * The policy to apply when this resource is removed from the application.
148 *
149 * @default cdk.RemovalPolicy.Destroy
150 */
151 readonly removalPolicy?: core.RemovalPolicy;
152}
153/**
154 * Deprecated.
155 * @deprecated use `core.CustomResource`
156 */
157export declare class CustomResource extends core.CustomResource {
158 constructor(scope: Construct, id: string, props: CustomResourceProps);
159}