UNPKG

2.6 kBTypeScriptView Raw
1import { CloudFormationCustomResourceEvent } from './cloudformation-custom-resource';
2import { Handler, Callback } from '../handler';
3
4// The CDK docs only specify 'important' properties, but in reality the incoming event
5// to the Lambda matches that of a traditional custom resource.
6// This includes the ResponseURL property which should not be used as the framework
7// itself will deal with delivering responses.
8export type CdkCustomResourceEvent = CloudFormationCustomResourceEvent & {
9 /**
10 * **This URL should not be used.** The CDK Provider Framework will call this URL
11 * automatically based on the response produced by the Lambda handler.
12 */
13 ResponseURL: string;
14};
15
16/**
17 * A custom resource based on the AWS CDK custom resource Provider Framework.
18 * This is not to be confused with traditional CloudFormation custom resources.
19 * @link https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html#handling-lifecycle-events-onevent
20 */
21export type CdkCustomResourceHandler = Handler<CdkCustomResourceEvent, CdkCustomResourceResponse>;
22export type CdkCustomResourceCallback = Callback<CdkCustomResourceResponse>;
23
24export interface CdkCustomResourceResponse {
25 PhysicalResourceId?: string;
26 Data?:
27 | {
28 [Key: string]: any;
29 }
30 | undefined;
31 // Any extra properties will be provided to the isComplete handler for asynchronous resources.
32 [Key: string]: any;
33}
34
35// IsComplete events will contain all normal request fields, as well as those returned from
36// the initial onEvent handler.
37export type CdkCustomResourceIsCompleteEvent = CdkCustomResourceEvent & CdkCustomResourceResponse;
38
39export type CdkCustomResourceIsCompleteResponse =
40 | CdkCustomResourceIsCompleteResponseSuccess
41 | CdkCustomResourceIsCompleteResponseWaiting;
42
43export interface CdkCustomResourceIsCompleteResponseSuccess {
44 IsComplete: true;
45 /**
46 * This will be merged with the `Data` property of the onEvent handler's response.
47 */
48 Data?:
49 | {
50 [Key: string]: any;
51 }
52 | undefined;
53}
54
55export interface CdkCustomResourceIsCompleteResponseWaiting {
56 IsComplete: false;
57}
58
59/**
60 * An asynchronous custom resource handler.
61 * @link https://docs.aws.amazon.com/cdk/api/latest/docs/custom-resources-readme.html#asynchronous-providers-iscomplete
62 */
63export type CdkCustomResourceIsCompleteHandler = Handler<
64 CdkCustomResourceIsCompleteEvent,
65 CdkCustomResourceIsCompleteResponse
66>;
67export type CdkCustomResourceIsCompleteCallback = Callback<CdkCustomResourceIsCompleteResponse>;