1 | import { Handler } from "../handler";
|
2 |
|
3 | /**
|
4 | * Named service-defined resource properties
|
5 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html#crpg-ref-request-properties
|
6 | */
|
7 | export interface CloudFormationCustomResourceResourcePropertiesCommon extends Record<string, any> {
|
8 | /**
|
9 | * The service token, such as an Amazon SNS topic ARN or Lambda function ARN. The service token must be from the same Region as the stack.
|
10 | */
|
11 | ServiceToken: string;
|
12 |
|
13 | /**
|
14 | * The maximum time, in seconds, that can elapse before a custom resource operation times out.
|
15 | * The value must be an integer from 1 to 3600. The default value is 3600 seconds (1 hour).
|
16 | */
|
17 | ServiceTimeout?: string;
|
18 | }
|
19 |
|
20 | /**
|
21 | * Lambda handler function for a Lambda-backed CloudFormation Custom Resource
|
22 | *
|
23 | * NOTE: responses are *not* returned from the Lambda handler but rather they are sent to the event ResponseURL.
|
24 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
25 | * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
|
26 | */
|
27 | export type CloudFormationCustomResourceHandler<
|
28 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
29 | TOldResourceProperties = TResourceProperties,
|
30 | > = Handler<CloudFormationCustomResourceEvent<TResourceProperties, TOldResourceProperties>, void>;
|
31 |
|
32 | /**
|
33 | * Request event sent to the Lambda handler for a Lambda-backed CloudFormation Custom Resource
|
34 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html#crpg-ref-request-fields
|
35 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
36 | * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
|
37 | */
|
38 | export type CloudFormationCustomResourceEvent<
|
39 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
40 | TOldResourceProperties = TResourceProperties,
|
41 | > =
|
42 | | CloudFormationCustomResourceCreateEvent<TResourceProperties>
|
43 | | CloudFormationCustomResourceUpdateEvent<TResourceProperties, TOldResourceProperties>
|
44 | | CloudFormationCustomResourceDeleteEvent<TResourceProperties>;
|
45 |
|
46 | /**
|
47 | * Response from a Lambda handler for a Lambda-backed CloudFormation Custom Resource
|
48 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html
|
49 | *
|
50 | * NOTE: responses are *not* returned from the Lambda handler but rather they are sent to the event ResponseURL.
|
51 | * @template TData User-defined output properties that are retuned from any invocation
|
52 | */
|
53 | export type CloudFormationCustomResourceResponse<TData extends Record<string, any> = Record<string, any>> =
|
54 | | CloudFormationCustomResourceSuccessResponse<TData>
|
55 | | CloudFormationCustomResourceFailedResponse<TData>;
|
56 |
|
57 | /**
|
58 | * Request properties that are common to all invocations of a Lambda-backed CloudFormation Custom Resource
|
59 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-requests.html#crpg-ref-request-fields
|
60 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
61 | */
|
62 | export interface CloudFormationCustomResourceEventCommon<
|
63 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
64 | > {
|
65 | /**
|
66 | * The service token, such as an Amazon SNS topic ARN or Lambda function ARN. The service token must be from the same Region as the stack.
|
67 | */
|
68 | ServiceToken: string;
|
69 |
|
70 | /**
|
71 | * The response URL identifies a presigned S3 bucket that receives responses from the custom resource provider to AWS CloudFormation.
|
72 | */
|
73 | ResponseURL: string;
|
74 |
|
75 | /**
|
76 | * The Amazon Resource Name (ARN) that identifies the stack that contains the custom resource.
|
77 | * Combining the `StackId` with the `RequestId` forms a value that you can use to uniquely identify a request on a particular custom resource.
|
78 | */
|
79 | StackId: string;
|
80 |
|
81 | /**
|
82 | * A unique ID for the request.
|
83 | * Combining the `StackId` with the `RequestId` forms a value that you can use to uniquely identify a request on a particular custom resource.
|
84 | */
|
85 | RequestId: string;
|
86 |
|
87 | /**
|
88 | * The template developer-chosen name (logical ID) of the custom resource in the AWS CloudFormation template. This is provided to facilitate communication between the custom resource provider and the template developer.
|
89 | */
|
90 | LogicalResourceId: string;
|
91 |
|
92 | /**
|
93 | * The template developer-chosen resource type of the custom resource in the CloudFormation template. Custom resource type names can be up to 60 characters long and can include alphanumeric and the following characters: `_@-`.
|
94 | */
|
95 | ResourceType: string;
|
96 |
|
97 | /**
|
98 | * This field contains the contents of the `Properties` object sent by the template developer. Its contents are defined by the custom resource provider.
|
99 | */
|
100 | ResourceProperties: TResourceProperties & CloudFormationCustomResourceResourcePropertiesCommon;
|
101 | }
|
102 |
|
103 | /**
|
104 | * Request properties specifically for the `Create` invocation of a Lambda-backed CloudFormation Custom Resource
|
105 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
106 | */
|
107 | export interface CloudFormationCustomResourceCreateEvent<
|
108 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
109 | > extends CloudFormationCustomResourceEventCommon<TResourceProperties> {
|
110 | /**
|
111 | * The request type is set by the CloudFormation stack operation (create-stack, update-stack, or delete-stack) that was initiated by the template developer for the stack that contains the custom resource.
|
112 | */
|
113 | RequestType: "Create";
|
114 | }
|
115 |
|
116 | /**
|
117 | * Request properties specifically for the `Update` invocation of a Lambda-backed CloudFormation Custom Resource
|
118 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
119 | * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
|
120 | */
|
121 | export interface CloudFormationCustomResourceUpdateEvent<
|
122 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
123 | TOldResourceProperties = TResourceProperties,
|
124 | > extends CloudFormationCustomResourceEventCommon<TResourceProperties> {
|
125 | /**
|
126 | * The request type is set by the CloudFormation stack operation (create-stack, update-stack, or delete-stack) that was initiated by the template developer for the stack that contains the custom resource.
|
127 | */
|
128 | RequestType: "Update";
|
129 |
|
130 | /**
|
131 | * A required custom resource provider-defined physical ID that is unique for that provider.
|
132 | * The value returned for a `PhysicalResourceId` can change custom resource update operations. If the value returned is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes the update as a replacement and sends a delete request to the old resource.
|
133 | */
|
134 | PhysicalResourceId: string;
|
135 |
|
136 | /**
|
137 | * Used only for `Update` requests. Contains the resource properties that were declared previous to the update request.
|
138 | */
|
139 | OldResourceProperties: TOldResourceProperties;
|
140 | }
|
141 |
|
142 | /**
|
143 | * Request properties specifically for the `Delete` invocation of a Lambda-backed CloudFormation Custom Resource
|
144 | * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
|
145 | */
|
146 | export interface CloudFormationCustomResourceDeleteEvent<
|
147 | TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
|
148 | > extends CloudFormationCustomResourceEventCommon<TResourceProperties> {
|
149 | /**
|
150 | * The request type is set by the CloudFormation stack operation (create-stack, update-stack, or delete-stack) that was initiated by the template developer for the stack that contains the custom resource.
|
151 | */
|
152 | RequestType: "Delete";
|
153 |
|
154 | /**
|
155 | * A required custom resource provider-defined physical ID that is unique for that provider.
|
156 | * The value returned for a `PhysicalResourceId` can change custom resource update operations. If the value returned is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes the update as a replacement and sends a delete request to the old resource.
|
157 | */
|
158 | PhysicalResourceId: string;
|
159 | }
|
160 |
|
161 | /**
|
162 | * Response properties that are common to all invocations of a Lambda-backed CloudFormation Custom Resource
|
163 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html
|
164 | * @template TData User-defined output properties that are retuned from any invocation
|
165 | */
|
166 | export interface CloudFormationCustomResourceResponseCommon<TData extends Record<string, any> = Record<string, any>> {
|
167 | /**
|
168 | * This value should be an identifier unique to the custom resource vendor, and can be up to 1 KB in size. The value must be a non-empty string and must be identical for all responses for the same resource.
|
169 | * The value returned for a `PhysicalResourceId` can change custom resource update operations. If the value returned is the same, it is considered a normal update. If the value returned is different, AWS CloudFormation recognizes the update as a replacement and sends a delete request to the old resource.
|
170 | */
|
171 | PhysicalResourceId: string;
|
172 |
|
173 | /**
|
174 | * The Amazon Resource Name (ARN) that identifies the stack that contains the custom resource. This response value should be copied verbatim from the request.
|
175 | */
|
176 | StackId: string;
|
177 |
|
178 | /**
|
179 | * A unique ID for the request. This response value should be copied verbatim from the request.
|
180 | */
|
181 | RequestId: string;
|
182 |
|
183 | /**
|
184 | * The template developer-chosen name (logical ID) of the custom resource in the AWS CloudFormation template. This response value should be copied verbatim from the request.
|
185 | */
|
186 | LogicalResourceId: string;
|
187 |
|
188 | /**
|
189 | * The custom resource provider-defined name-value pairs to send with the response. You can access the values provided here by name in the template with `Fn::GetAtt`.
|
190 | * NOTE: If the name-value pairs contain sensitive information, you should use the `NoEcho` field to mask the output of the custom resource. Otherwise, the values are visible through APIs that surface property values (such as `DescribeStackEvents`).
|
191 | */
|
192 | Data?: TData | undefined;
|
193 |
|
194 | /**
|
195 | * Indicates whether to mask the output of the custom resource when retrieved by using the `Fn::GetAtt` function. If set to `true`, all returned values are masked with asterisks (*****), __except for those stored in the `Metadata` section of the template__. AWS CloudFormation does not transform, modify, or redact any information you include in the `Metadata` section. The default value is `false`.
|
196 | */
|
197 | NoEcho?: boolean | undefined;
|
198 | }
|
199 |
|
200 | /**
|
201 | * Response properties that are specifically for a response indicating succesful invocation of a Lambda-backed CloudFormation Custom Resource
|
202 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html
|
203 | * @template TData User-defined output properties that are retuned from any invocation
|
204 | */
|
205 | export interface CloudFormationCustomResourceSuccessResponse<TData extends Record<string, any> = Record<string, any>>
|
206 | extends CloudFormationCustomResourceResponseCommon<TData>
|
207 | {
|
208 | /**
|
209 | * The status value sent by the custom resource provider in response to an AWS CloudFormation-generated request.
|
210 | */
|
211 | Status: "SUCCESS";
|
212 |
|
213 | /**
|
214 | * Describes the reason for a failure response.
|
215 | */
|
216 | Reason?: string | undefined;
|
217 | }
|
218 |
|
219 | /**
|
220 | * Response properties that are specifically for a response indicating failed invocation of a Lambda-backed CloudFormation Custom Resource
|
221 | * Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref-responses.html
|
222 | * @template TData User-defined output properties that are retuned from any invocation
|
223 | */
|
224 | export interface CloudFormationCustomResourceFailedResponse<TData extends Record<string, any> = Record<string, any>>
|
225 | extends CloudFormationCustomResourceResponseCommon<TData>
|
226 | {
|
227 | /**
|
228 | * The status value sent by the custom resource provider in response to an AWS CloudFormation-generated request.
|
229 | */
|
230 | Status: "FAILED";
|
231 |
|
232 | /**
|
233 | * Describes the reason for a failure response.
|
234 | */
|
235 | Reason: string;
|
236 | }
|