Skip to content

Instantly share code, notes, and snippets.

@bwinant
Created February 7, 2019 07:19
Show Gist options
  • Save bwinant/ffc669a9b65035c69636dd5536e9c3cb to your computer and use it in GitHub Desktop.
Save bwinant/ffc669a9b65035c69636dd5536e9c3cb to your computer and use it in GitHub Desktop.
CloudFormation CustomResource lambda response
const sendResponse = async (event, context, status, data = {}) => {
const response = {
Status: status,
RequestId: event.RequestId,
LogicalResourceId: event.LogicalResourceId,
StackId: event.StackId,
PhysicalResourceId: context.functionName,
Data: data
};
try {
console.log(`Sending ${JSON.stringify(response)}`);
const result = await axios.put(event.ResponseURL, response);
console.log(`Result is ${result.status}`);
}
catch (err) {
// TODO: if this happens, then what?
console.log(err);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment