Skip to content

clauseHQ/aws-cfn-custom-resource-response

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

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);
};

About

AWS Cloudformation Custom Resource Response

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%