@vissree_s/cfn-response-async
v0.0.1
Published
A module for managing lambda-funciton backed custom resources in AWS CloudFormation with async support
Downloads
2
Maintainers
Readme
README
This package is an async version of cfn-response module.
The module includes a send method, which sends a Custom resource response object corresponding to the received request object and returns a promise, so that it can be used within Async nodejs handlers.
Sample usage
const response = require("cfn-response-async");
async function someAsyncLogicToRun() {
return "All good!";
}
exports.handler = async (event, context) => {
console.log(event);
console.log(context);
var res;
try {
const outputValue = await someAsyncLogicToRun();
const responseData = {
Value: outputValue,
};
res = await response.send(event, context, response.SUCCESS, responseData);
} catch (error) {
console.log(error);
res = await response.send(event, context, response.FAILED);
}
console.log("Status code: " + res.statusCode);
console.log("Status message: " + res.statusMessagee);
return res.statusCode;
};