in src/cfn-custom-resources/react-app/cfn-response.ts [11:46]
export async function sendCfnResponse(props: {
event: {
StackId: string;
RequestId: string;
LogicalResourceId: string;
ResponseURL: string;
};
status: Status;
reason?: string;
data?: {
[key: string]: string;
};
physicalResourceId?: string;
}) {
const response = {
Status: props.status,
Reason: props.reason?.toString() || "See CloudWatch logs",
PhysicalResourceId: props.physicalResourceId || "no-explicit-id",
StackId: props.event.StackId,
RequestId: props.event.RequestId,
LogicalResourceId: props.event.LogicalResourceId,
Data: props.data || {},
};
await new Promise<void>((resolve, reject) => {
const options = {
method: "PUT",
headers: { "content-type": "" },
};
request(props.event.ResponseURL, options)
.on("error", (err) => {
reject(err);
})
.end(JSON.stringify(response), "utf8", resolve);
});
}