Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions lib/plugins/aws/custom-resources/resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,30 @@ function getEnvironment(context) {
};
}

// function handlerWrapper(handler, PhysicalResourceId) {
// return async (event, context, callback) => {
// // extend the `event` object to include the PhysicalResourceId
// event = Object.assign({}, event, { PhysicalResourceId });
// return Promise.resolve(handler(event, context, callback))
// .then(
// (result) => response(event, context, 'SUCCESS', result),
// (error) => response(event, context, 'FAILED', {}, error)
// )
// .then((result) => callback(null, result), callback);
// };
// }
function handlerWrapper(handler, PhysicalResourceId) {
return async (event, context, callback) => {
// extend the `event` object to include the PhysicalResourceId
return async (event, context) => { // Removed callback parameter
event = Object.assign({}, event, { PhysicalResourceId });
return Promise.resolve(handler(event, context, callback))
.then(
(result) => response(event, context, 'SUCCESS', result),
(error) => response(event, context, 'FAILED', {}, error)
)
.then((result) => callback(null, result), callback);

try {
const result = await handler(event, context);
await response(event, context, 'SUCCESS', result);
return result;
} catch (error) {
await response(event, context, 'FAILED', {}, error);
throw error;
}
};
}

Expand Down