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 { DynamoDBSeeder, Seeds } from '@cloudcomponents/cdk-dynamodb-seeder';
import { Stack, StackProps, RemovalPolicy } from 'aws-cdk-lib';
import { Table, AttributeType } from 'aws-cdk-lib/aws-dynamodb';
import { Bucket } from 'aws-cdk-lib/aws-s3';
import { Construct } from 'constructs';
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-2.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9d654fc372fa5ed28fddfe8304bed4b3fb8961672ac9fb7a986dfa3d59e67e6 |
|
MD5 | 1d93c9ac5a5eb23fb62f305197f4df63 |
|
BLAKE2b-256 | 1515fbff61d2aa62a784a9bd6d021d1556d93a773cb5a1bda19a7c0246d330b7 |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f5c6764cd8e7118362d7c715a83590cc4c534757d0a2cefd724494423c67ec0 |
|
MD5 | ac1b9698ac78664f9126a2c22ce02c10 |
|
BLAKE2b-256 | b3f38f6bde27a5778fb815d2904334927b7cb1df17f7cca8b0fb2e6120be299b |