@reapit-cdk/custom-resource-wrapper
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@reapit-cdk/custom-resource-wrapper

npm version npm downloads coverage: 99.02%25

This module helps write custom resource handlers. It's designed to work with the Custom Resource Provider Framework. It accepts an object which contains event handlers for onCreate, and optionally, onUpdate, and onDelete. Anything returned from onCreate and onUpdate is returned as data attributes on the resulting custom resource.

Package Installation:

yarn add --dev @reapit-cdk/custom-resource-wrapper
# or
npm install @reapit-cdk/custom-resource-wrapper --save-dev

Usage

import { customResourceWrapper } from '@reapit-cdk/custom-resource-wrapper'

import { createThing, deleteThing } from './your-module'

export const onEvent = customResourceWrapper({
  onCreate: async ({ aProperty }) => {
    const { aDataAttribute } = await createThing(aProperty)
    return {
      aDataAttribute,
    }
  },
  onUpdate: async ({ aProperty }, oldProps) => {
    if (aProperty !== oldProps.aProperty) {
      await deleteThing(oldProps.aProperty)
      const { aDataAttribute } = await createThing(aProperty)
      return {
        aDataAttribute,
      }
    }
  },
  onDelete: async ({ aProperty }) => {
    await deleteThing(aProperty)
  },
})

/@reapit-cdk/custom-resource-wrapper/

    Package Sidebar

    Install

    npm i @reapit-cdk/custom-resource-wrapper

    Weekly Downloads

    2

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    7.68 kB

    Total Files

    5

    Last publish

    Collaborators

    • joshbalfour