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.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16da1214d7384cc9d51a10793eb220818cc2ab28245ed73b39629a947c4476c1 |
|
MD5 | 52ffce2afa6f6d4e9967ed0ceb9fc17d |
|
BLAKE2b-256 | e1aa84dbf7b7d0ec6aecf51f8a96a52aeb00773137a805438f66689915922ad3 |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59da6296aad516539da98b115c5a3203cee1fd3648cbd9c7c831b07ceb88b42d |
|
MD5 | 2e2ad1634ce5a00390f86f73cea4dd28 |
|
BLAKE2b-256 | 6fe12c832836779674db9d8a1a7ca3dd30d6e268f4d4c0bf339a9d639fb08fc2 |