Serverless Dynamodb Fixtures

homepage icon https://github.com/chechu/serverless-dynamodb-fixtures
Follow @chechu

Tracked

NPM Downloads Last Month
101
Issues
1
Stars
3
Forks
1
Watchers
3
Watch Star Fork Issue Download License NPM Build Status Coverage Status Contributors

Repo README Contents:

serverless npm version License: MIT

serverless-dynamodb-fixtures

Serverless plugin to load data on DynamoDB tables.

This Plugin Requires

Usage

You can use this plugin in two ways:

See the configuration flag enable, for each fixture block, for more information.

Configuration

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 accepted configuration is an array of fixtures, where each fixture has the following variables:

Important: sources or rawsources must be defined (at least one of them).

Examples

Serverless configuration

plugins:
  - serverless-dynamodb-fixtures

custom:
  fixtures:
    - 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

Autogeneration of id

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

Fixtures

Source in yml format

- id: 1
  name: Jack London
- id: 2
  name: John Doe

Source in json format

[
    {"id":1, "name":"Jack London"},
    {"id":2, "name":"John Doe"}
]

Thanks