serverless-dynamodb-seed v0.3.0
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-devAdd the plugin to your serverless.yml file:
plugins:
- serverless-dynamodb-seedConfigure
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.jsonEach 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:
seedExample:
table: myDynamodbTable
sources:
- path/to/my/seed.json
otherSeed:
table: myOtherDynamodbTable
sources:
- path/to/my/otherSeed.jsonThis command will run all the available seeds.
$ sls dynamodb:seedIf you want to run just one seed:
$ sls dynamodb:seed --seed otherSeedWarning
WATCH OUT! THIS PLUGIN MAY OVERWRITE DATA ON YOUR DYNAMO DB TABLE!