Tracked
- NPM Downloads Last Month
- 3578
- Issues
- 0
- Stars
- 0
- Forks
- 0
- Watchers
- 0
Serverless plugin to load data on DynamoDB tables.
You can use this plugin in two ways:
sls fixtures
from your CLI.sls deploy
). A hook is linked in this point (after deploying).See the configuration flag enable
, for each fixture block, for more information.
You should include the plugin as dev dependency, and in your serverless.yml file. Then, as a custom variable, you should include a fixtures
variable with the configuration of the plugin. The fixtures configuration should contain a rules
element. and optionally an endpoint
element if you want to use a local instance of DynamoDB (remember to set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables if you use dynamodb local).
The accepted rules configuration is an array of fixtures, where each fixture has the following variables:
sls fixtures
). This is the default value.sls deploy
).Important: sources
or rawsources
must be defined (at least one of them).
plugins:
- serverless-dynamodb-fixtures
custom:
fixtures:
endpoint: http://localhost:8000
rules:
- table: TABLE1-${self:custom.stage}
[enable: true]
sources:
- ./file1-${self:custom.stage}.yml
- ./file2-${self:custom.stage}.json
rawsources:
- ./rawFormatFile1-${self:custom.stage}.yml
- table: TABLE2-${self:custom.stage}
[stage: test]
[concurrentWrites: 5]
sources:
- ./file3-${self:custom.stage}.yml
serverless.yml
plugins:
- serverless-dynamodb-fixtures
custom:
fixtures:
- table: TABLE1-${self:custom.stage}
autogeneratedId: id
sources:
- ./file.yml
file.yml
- name: Jack London
- name: John Doe
It will be loaded in DynamoDB as follow:
- id: 45745c60-7b1a-11e8-9c9c-2d42b21b1a3e
name: Jack London
- id: 35625c60-8b1f-22e9-1c3c-1ae1c16a2f4e
name: John Doe
- id: 1
name: Jack London
- id: 2
name: John Doe
[
{"id":1, "name":"Jack London"},
{"id":2, "name":"John Doe"}
]