0.0.9 • Published 7 years ago

cfn-custom-resource-helper v0.0.9

Weekly downloads
12
License
MIT
Repository
github
Last release
7 years ago

cfn-custom-resource-helper

NPM Version

Helper library for Lambda function as a backend of CloudFormation custom resource.

Can be combined with Serverless Framework.

Usage

See example which creates a S3 object as an custom resource.

Install

npm install --save cfn-custom-resource-helper

Write handler code

const {cfnCustomResource} = require("cfn-custom-resource-helper");

module.exports.cfnCustomResource = (event, context, callback) => {
  cfnCustomResource(event, context, {
    onCreate() {
      /* Code to create resource goes here. */
      /* Please return Promise<{id: "**PhysicalResourceId**", data?: { <data to reference with Fn::GetAtt> }}> */
    },

    onUpdate() {
      /* Code to update resource goes here. */
      /* Please return Promise<{id: "**PhysicalResourceId**", data?: { <data to reference with Fn::GetAtt> }}> */
    },

    onDelete() {
      /* Code to delete resource goes here. */
      /* Please return Promise<{id: "**PhysicalResourceId**", data?: { <data to reference with Fn::GetAtt> }}> */
    },
  }).then(result => {
    callback(undefined, result);
  }).catch(err => {
    callback(err);
  });;
};

Define custom resource

If you use Serverless framework, you can define additional resource on serverless.yml.

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.1

7 years ago