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.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 319f270796d7325858e06fb22b8bd9e53b4226a28aad722668f26751eea2edce |
|
MD5 | 62f7650e22203c1fc1aa37639e572357 |
|
BLAKE2b-256 | a957f723e7701dd7e8d3cad94b0ed949a4afb66dd4b46f35c39a78f6defde4ce |
Close
Hashes for cloudcomponents.cdk_dynamodb_seeder-2.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e81f56713c9715d1ce474bc6b588dd76f27718424bb007ea1ee2d2d4c85e4ca9 |
|
MD5 | 6665ec9ae7e8e74b5a65600fbef1b4ff |
|
BLAKE2b-256 | 4fd55f133fbe343eae3d8927dbdc28885acf6e5e4e77a9abc492241ba0969414 |