aws-cdk-dynamodb-seeder
A simple CDK JSON seeder for DynamoDB
Why this package
Glad you asked!
Using AWS CDK for automating infratructure deployments is an amazing way of integrating the development and operations into one process and one codebase.
However, building dev or test environments that come pre-populated with data can be tricky, especially when using Amazon DynamoDB.
How do I use it
Install using your favourite package manager:
yarn add aws-cdk-dynamodb-seeder
Example usage
import { Seeder } from 'aws-cdk-dynamodb-seeder';
...
const myTable = new Table(stack, "MyTable", {
tableName: "MyTable",
partitionKey: { name: "Id", type: AttributeType.STRING },
});
...
new Seeder(stack, "MySeeder", {
table: myTable,
tableName: "MyTable",
setup: require("./items-to-put.json"),
teardown: require("./keys-to-delete.json"),
refreshOnUpdate: true
});
Importing seed data
Data passed into setup
("Items" to put) or teardown
("Keys" to delete) should be an array
of JavaScript objects (that are, in turn, representations of string
to AttributeValue maps).