Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@puresec/sequelize-sync-cfn-custom-resource

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@puresec/sequelize-sync-cfn-custom-resource

This library supplies a custom resource handler generator that uses your models and migrations in a webpackable way to sync/migrate your database.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

sequelize-sync-cfn-custom-resource

This library supplies a custom resource handler generator that uses your models and migrations in a webpackable way to sync/migrate your database.

Usage

Install

npm install --save @puresec/sequelize-sync-cfn-custom-resource

Migration Preparation

For your migrations to be webpackable they must be required by some module.

Use the prepare-sequelize-migrations binary that arrives with this module, which creates a .migrations.js file that will soon be required by your custom resource.

./node_modules/.bin/prepare-sequelize-migrations

The generated file should probably be git ignored.

See the script for more complex usage.

Custom Resource Handler

In your own JavaScript module:

const createHandler = require('@puresec/sequelize-sync-cfn-custom-resource');

module.exports.handler = createHandler({
  requireModels: () => require('./models'),
  requireMigrations: () => require('./.migrations'),
  logging: (message) => { /* ... */ }, // optional
});

Use your module's handler for the function that is used as the custom resource.

How it works

During the CloudFormation lifecycle, the custom resource will:

  • create: Sync the initial schema and mark all migrations as executed.
  • update: Run all pending migrations (make sure the resource has a UUID updated with every new migration).
  • delete: Does nothing for now.

The createHandler function receives 2 functions:

  • requireModels: returns your required models (must export sequelize and Sequelize).
  • requireMigrations: returns your required migrations, generated using the prepare-sequelize-migrations binary.

These functions are supplied so that webpack can pack the relevant JavaScript files into the function's artifact, with your own code.

They are supplied as functions so that failure to require them will not prevent sending a response to CloudFormation (using safe-cfn-custom-resource).

Development

Publish a new version

Set the "version" in package.json, then run:

npm publish --access public

(if you have permissions)

FAQs

Package last updated on 21 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc