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.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2681866a91d3598d8166a7cb9e652e3fbc8a790278d6af1bda03be54a9216ccc |
|
MD5 | 8d61c9e34bef3a2e2afff76422c84039 |
|
BLAKE2b-256 | de82d9590a5f177ed92bd1291ddec21e276635a8a89bebdfa7b5cf01cdac2264 |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-2.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd42d675bd1b470f07f414157cf60aca0a8340c810be44fd616fa73bd6f3fe2b |
|
MD5 | b83283989426df7b53ac115370675544 |
|
BLAKE2b-256 | d80b8b56cda495138aecdff1bd4bb8ef1a60d7f830edebd2b8b20664027bf4f5 |