A seeder for dynamodb tables
Project description
@cloudcomponents/cdk-dynamodb-seeder
A seeder for dynamodb tables
Install
TypeScript/JavaScript:
npm i @cloudcomponents/cdk-dynamodb-seeder
Python:
pip install cloudcomponents.cdk-dynamodb-seeder
How to use
import * as path from 'path';
import { Construct, Stack, StackProps, RemovalPolicy } from '@aws-cdk/core';
import { Table, AttributeType } from '@aws-cdk/aws-dynamodb';
import { Bucket } from '@aws-cdk/aws-s3';
import { DynamoDBSeeder, Seeds } from '@cloudcomponents/cdk-dynamodb-seeder';
export class DynamoDBSeederStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
const table = new Table(this, 'Table', {
partitionKey: {
name: 'id',
type: AttributeType.NUMBER,
},
removalPolicy: RemovalPolicy.DESTROY,
});
new DynamoDBSeeder(this, 'JsonFileSeeder', {
table,
seeds: Seeds.fromJsonFile(path.join(__dirname, '..', 'seeds.json')),
});
new DynamoDBSeeder(this, 'InlineSeeder', {
table,
seeds: Seeds.fromInline([
{
id: 3,
column: 'foo',
},
{
id: 4,
column: 'bar',
},
]),
});
const seedsBucket = Bucket.fromBucketName(
this,
'SeedsBucket',
'my-seeds-bucket',
);
new DynamoDBSeeder(this, 'BucketSeeder', {
table,
seeds: Seeds.fromBucket(seedsBucket, 'seeds.json'),
});
}
}
API Reference
See API.md.
Example
See more complete examples.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cloudcomponents.cdk-dynamodb-seeder-1.49.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 388470ef5180b7c8b5b209875e1fc93889418af287d73984ba15b3618c4777e0 |
|
MD5 | b6c1f14b08c68452e3f7fa3e92efabe4 |
|
BLAKE2b-256 | 8e7e2753483890fd6dd44e05532389334b04908bdd3c45268c81ab4c1a9a6e18 |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-1.49.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f84458821f2083cf628f39a1563ded95e902a4c7ad61eeabbca9078c387a0f1 |
|
MD5 | c05979e09cf13cd979164da90c094ec5 |
|
BLAKE2b-256 | 2325139a109c012bb99dcaf3a24b65e2a6d50f59cc37df324218ddea566c8b27 |