npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2021 – Pkg Stats / Ryan Hefner

aws-cdk-dynamodb-seeder

v1.56.1

Published

A simple CDK JSON seeder for DynamoDB

Downloads

3,157

Readme

aws-cdk-dynamodb-seeder Mentioned in Awesome CDK

build codecov dependencies Status npm

npm version NuGet version PyPI version Maven Central

A simple CDK JSON seeder for DynamoDB

Why this package

Glad you asked!

Using AWS CDK for automating infrastructure 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 TypeScript 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,
    setup: require("./items-to-put.json"),
    teardown: require("./keys-to-delete.json"),
    refreshOnUpdate: true  // runs setup and teardown on every update, default false
});

For a more in-depth example, see: elegantdevelopment/aws-cdk-dynamodb-seeder-examples.

Importing seed data

Data passed into setup ("Items" to put) or teardown ("Keys" to delete) should be an array of objects (that are, in turn, representations of string to AttributeValue maps).

Versioning

We will attempt to align the major and minor version of this package with AWS CDK, but always check our release descriptions for compatibility.

We currently support GitHub package.json dependency version (prod)

Internals

Behind the scenes we use an AwsCustomResource as a representation of the related table's seed state. The custom resource's event handlers invoke a Function to perform setup and/or teardown actions.

Deploying a stack

On deployment, we write copies of your seed data locally and use a BucketDeployment to write it to an S3 Bucket.

We then create the handler function and custom resource to field seed requests (the onCreate event will immediate fire as the stack deploys, reading the data from the bucket and seeding the table using AWS.DynamoDB.DocumentClient).

Updating a stack

On a stack update, the onUpdate handler is triggered when refreshOnUpdate is true.

This will run AWS.DynamoDB.DocumentClient.delete() on every teardown "Key" followed by AWS.DynamoDB.DocumentClient.put() on every setup "Item".

Destroying a stack

When the stack is destroyed, the event handler's onDelete function will be invoked, providing teardown is set.

This simply runs AWS.DynamoDB.DocumentClient.delete() on every teardown "Key" before destroying the Seeder's resources.