0.0.7 • Published 4 years ago

aws-cfn-custom-resource-response v0.0.7

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

aws-cfn-custom-resource-response

A library that builds & sends the right custom resource response out of the lambda event

example

const sendAWSResponse = require('aws-cfn-custom-resource-response');

module.exports.handler = (event, context, callback) => {
  if (!event) {
    return callback('No event received');
  }

  const { RequestType } = event;
  const sendResponse = sendAWSResponse(event);

  if (RequestType === 'Delete') {
    return sendResponse({
      Status: 'SUCCESS'
    }, callback);
  }

  if (RequestType === 'Create' || RequestType === 'Update') {
    // do something
    const success = true;

    if (success) {
      return sendResponse({
        Status: 'SUCCESS'
      }, callback);
    }

    return sendResponse({
      Status: 'FAILED',
      Reason: 'Reason for failure diplayed in cloudformation console'
    }, callback);
  }

  return sendResponse({
    Status: 'FAILED',
    Reason: `Unsupported request type ${RequestType}`
  }, callback);
};
0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago