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
# Example automatically generated from non-compiling source. May contain errors.
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.48.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2ca4874f12c8a1bf216a13ebea343eafd4170c577161de49379fbac827a781b |
|
MD5 | 498ac40fe9c42cd1e3d116015dd19b48 |
|
BLAKE2b-256 | 3a52e5a0cf944ffcd8385a7ba77aa7487a1b22b4a8e19b77faf110ed6865ecf5 |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-1.48.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c57f7587734b309d5d7a3df6a35b2bfa058b29a45d70d3b6e676b8049a507d |
|
MD5 | 6e33630de358169ff07a4a4613ddc12f |
|
BLAKE2b-256 | acd974b95385188d8e55df7fc4bb6f6444ef1e4d89fe28d823eff040f9d80480 |