UNPKG

9.5 kBTypeScriptView Raw
1import { Callback, Handler } from "../handler";
2import {
3 CloudFormationCustomResourceEvent,
4 CloudFormationCustomResourceResourcePropertiesCommon,
5} from "./cloudformation-custom-resource";
6
7/**
8 * Request event sent to the Lambda `OnEvent` handler for a CDK Custom Resource
9 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#handling-lifecycle-events-onevent
10 * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
11 * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
12 */
13export type CdkCustomResourceEvent<
14 TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
15 TOldResourceProperties = TResourceProperties,
16> =
17 & CloudFormationCustomResourceEvent<TResourceProperties, TOldResourceProperties>
18 & {
19 /**
20 * The response URL identifies a presigned S3 bucket that receives responses from the custom resource provider to AWS CloudFormation.
21 *
22 * **This URL should not be used.**
23 * The CDK Provider Framework will call this URL automatically based on the response produced by the Lambda handler.
24 */
25 ResponseURL: string;
26 };
27
28/**
29 * Lambda handler function for the `OnEvent` CDK Custom Resource
30 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#handling-lifecycle-events-onevent
31 *
32 * NOTE: this is not to be confused with traditional CloudFormation custom resources.
33 * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
34 * @template TData User-defined output properties that are retuned from any invocation
35 * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
36 */
37export type CdkCustomResourceHandler<
38 TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
39 TData extends Record<string, any> = Record<string, any>,
40 TOldResourceProperties = TResourceProperties,
41> = Handler<CdkCustomResourceEvent<TResourceProperties, TOldResourceProperties>, CdkCustomResourceResponse<TData>>;
42
43/**
44 * Lambda `OnEvent` callback function for a CDK Custom Resource
45 * @template TData User-defined output properties that are retuned from any invocation
46 */
47export type CdkCustomResourceCallback<TData extends Record<string, any>> = Callback<CdkCustomResourceResponse<TData>>;
48
49/**
50 * Response from the `OnEvent` Lambda handler for a CDK Custom Resource
51 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#handling-lifecycle-events-onevent
52 * @template TData User-defined output properties that are retuned from any invocation
53 */
54export interface CdkCustomResourceResponse<TData extends Record<string, any> = Record<string, any>> {
55 /**
56 * 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.
57 * 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.
58 *
59 * If omitted for `Create` events, the event's `RequestId` will be used.
60 * For `Update`, the current physical ID will be used. If a different value is returned, CloudFormation will follow with a subsequent `Delete` for the previous ID (resource replacement).
61 * For `Delete`, it will always return the current physical resource ID, and if the user returns a different one, an error will occur.
62 */
63 PhysicalResourceId?: string;
64
65 /**
66 * 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`.
67 * 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`).
68 */
69 Data?: TData;
70
71 /**
72 * 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`.
73 */
74 NoEcho?: boolean;
75
76 /**
77 * Any other field included in the response will be passed through to `isComplete`. This can sometimes be useful to pass state between the handlers.
78 */
79 [Key: string]: any;
80}
81
82/**
83 * Request event sent to the Lambda `IsComplete` handler for an asynchronous CDK Custom Resource
84 * The input event to isComplete includes all request fields, combined with all fields returned from onEvent. If PhysicalResourceId has not been explicitly returned from onEvent, it's value will be calculated based on heuristics.
85 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#asynchronous-providers-iscomplete
86 * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
87 * @template TData User-defined output properties that are retuned from any invocation
88 * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
89 */
90export type CdkCustomResourceIsCompleteEvent<
91 TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
92 TData extends Record<string, any> = Record<string, any>,
93 TOldResourceProperties = TResourceProperties,
94> = CdkCustomResourceEvent<TResourceProperties, TOldResourceProperties> & CdkCustomResourceResponse<TData>;
95
96/**
97 * Common response properties from the `IsComplete` Lambda handler for a CDK Custom Resource
98 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#asynchronous-providers-iscomplete
99 * @template TData User-defined output properties that are retuned from any invocation
100 */
101export type CdkCustomResourceIsCompleteResponse<TData extends Record<string, any> = Record<string, any>> =
102 | CdkCustomResourceIsCompleteResponseSuccess<TData>
103 | CdkCustomResourceIsCompleteResponseWaiting;
104
105/**
106 * Response properties that are specifically for a successful `IsComplete` response for a CDK Custom Resource
107 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#asynchronous-providers-iscomplete
108 * @template TData User-defined output properties that are retuned from any invocation
109 */
110export interface CdkCustomResourceIsCompleteResponseSuccess<TData extends Record<string, any> = Record<string, any>> {
111 /**
112 * Indicates the operation has finished.
113 */
114 IsComplete: true;
115
116 /**
117 * 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`.
118 * These attributes will be **merged** with the ones returned from `onEvent`.
119 */
120 Data?: TData;
121}
122
123/**
124 * Response properties that are specifically for a still waiting `IsComplete` response for a CDK Custom Resource
125 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#asynchronous-providers-iscomplete
126 */
127export interface CdkCustomResourceIsCompleteResponseWaiting {
128 /**
129 * Indicates the operation has not finished.
130 */
131 IsComplete: false;
132}
133
134/**
135 * Lambda `IsComplete` handler function for asynchronous CDK Custom Resources
136 * Reference: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.custom_resources-readme.html#asynchronous-providers-iscomplete
137 * @template TResourceProperties User-defined input properties passed to the Custom Resource as part of any invocation
138 * @template TOnEventData User-defined output properties that are retuned from any invocation of the `OnEvent` function
139 * @template TOldResourceProperties User-defined input properties passed to the Custom Resource as part of an `Update` invocation
140 * @template TIsCompleteData User-defined output properties that are retuned from any invocation of the `IsComplete` function
141 */
142export type CdkCustomResourceIsCompleteHandler<
143 TResourceProperties = CloudFormationCustomResourceResourcePropertiesCommon,
144 TOnEventData extends Record<string, any> = Record<string, any>,
145 TOldResourceProperties = TResourceProperties,
146 TIsCompleteData extends Record<string, any> = TOnEventData,
147> = Handler<
148 CdkCustomResourceIsCompleteEvent<TResourceProperties, TOnEventData, TOldResourceProperties>,
149 CdkCustomResourceIsCompleteResponse<TIsCompleteData>
150>;
151
152/**
153 * Lambda `IsComplete` callback function for a CDK Custom Resource
154 * @template TData User-defined output properties that are retuned from any invocation
155 */
156export type CdkCustomResourceIsCompleteCallback<TData extends Record<string, any> = Record<string, any>> = Callback<
157 CdkCustomResourceIsCompleteResponse<TData>
158>;