|
1 | 1 | import { CloudFormationCustomResourceEvent, Context } from "aws-lambda"; |
2 | 2 |
|
| 3 | +/** |
| 4 | + * Response status indicating the custom resource operation succeeded. |
| 5 | + */ |
3 | 6 | export const SUCCESS: "SUCCESS"; |
| 7 | + |
| 8 | +/** |
| 9 | + * Response status indicating the custom resource operation failed. |
| 10 | + * CloudFormation will roll back the stack if FAILED is returned during create or update. |
| 11 | + */ |
4 | 12 | export const FAILED: "FAILED"; |
| 13 | + |
| 14 | +/** |
| 15 | + * Union type of the two possible response statuses for a CloudFormation custom resource. |
| 16 | + */ |
5 | 17 | export type ResponseStatus = typeof SUCCESS | typeof FAILED; |
6 | 18 |
|
| 19 | +/** |
| 20 | + * Sends a response to the CloudFormation pre-signed S3 URL to signal the result |
| 21 | + * of a custom resource operation. Must be called in every code path of a Lambda-backed |
| 22 | + * custom resource — if not called, the CloudFormation stack will hang until it times out. |
| 23 | + * |
| 24 | + * Note: this function does not return a Promise. Lambda completion is signaled via |
| 25 | + * `context.done()` internally. Do not use `await` with this function. |
| 26 | + * |
| 27 | + * @param event - The CloudFormation custom resource event containing the ResponseURL, |
| 28 | + * StackId, RequestId, and LogicalResourceId. |
| 29 | + * @param context - The Lambda context object, used for the log stream name and signaling completion. |
| 30 | + * @param responseStatus - Whether the operation succeeded or failed. Use `SUCCESS` or `FAILED`. |
| 31 | + * @param responseData - Optional key-value data to return to CloudFormation, |
| 32 | + * accessible via `Fn::GetAtt` in the template. |
| 33 | + * @param physicalResourceId - The unique identifier of the custom resource. |
| 34 | + * Defaults to the Lambda log stream name if not provided. |
| 35 | + * WARNING: changing this value on an update will cause CloudFormation to delete the old resource. |
| 36 | + */ |
7 | 37 | export function send( |
8 | 38 | event: CloudFormationCustomResourceEvent, |
9 | 39 | context: Context, |
10 | 40 | responseStatus: ResponseStatus, |
11 | | - responseData?: object, |
| 41 | + responseData?: Record<string, unknown>, |
12 | 42 | physicalResourceId?: string, |
13 | | - noEcho?: boolean, |
14 | 43 | ): void; |
0 commit comments