Coder Social home page Coder Social logo

serverless-dynamodb-seed's Introduction

serverless-dynamodb-seed

This is a simple plugin for Serverless Framework to perform seeds on dynamodb databases based on serverless.yml.

Install

$ npm install serverless-dynamodb-seed --save-dev

Add the plugin to your serverless.yml file:

plugins:
  - serverless-dynamodb-seed

Configure

The configuration of the plugin is done by defining a custom: seed object in your serverless.yml with your specific configuration. You must set at least one seed for this plugin to work correctly.

You can set multiple named seed for running just one if needed.

custom:
  seed:
    mySeedName:
      table: myDynamodbTable # Name of the DynamoDB Table - In this version, Cloudformation references are not accepted.
      sources:
        - path/to/my/seed.json

Each named seed can have only one table, but may have multiple source files. This plugin will read all the files, concat them and save them do AWS.

Each source file must be a JSON array.

[
  {
    "id": 1,
    "name": "myRecordName"
  },
  {
    "id": 2,
    "name": "myOtherRecord"
  }
]

Usage

If you have multiple named seeds:

custom:
  seed:
    seedExample:
      table: myDynamodbTable
      sources:
        - path/to/my/seed.json
    otherSeed:
      table: myOtherDynamodbTable
      sources:
        - path/to/my/otherSeed.json

This command will run all the available seeds.

$ sls dynamodb:seed

If you want to run just one seed:

$ sls dynamodb:seed --seed otherSeed

Stages

Since this is a serverless plugin, if you run with the correct profile and/or stage, it will just use your configured database. So, you can run like:

sls dynamodb:seed --stage dev --profile my-aws-profile

Warning

WATCH OUT! THIS PLUGIN MAY OVERWRITE DATA ON YOUR DYNAMO DB TABLE!

serverless-dynamodb-seed's People

Contributors

arielschvartz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.