[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)
# @cloudcomponents/cdk-dynamodb-seeder
[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)
[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)
[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-dynamodb-seeder)
[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-dynamodb-seeder/)
> A seeder for dynamodb tables
## Install
TypeScript/JavaScript:
```bash
npm i @cloudcomponents/cdk-dynamodb-seeder
```
Python:
```bash
pip install cloudcomponents.cdk-dynamodb-seeder
```
## How to use
```python
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](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-dynamodb-seeder/API.md).
## Example
See more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).
## License
[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-dynamodb-seeder/LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/cloudcomponents/cdk-constructs",
"name": "cloudcomponents.cdk-dynamodb-seeder",
"maintainer": null,
"docs_url": null,
"requires_python": "~=3.8",
"maintainer_email": null,
"keywords": null,
"author": "hupe1980",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/a9/57/f723e7701dd7e8d3cad94b0ed949a4afb66dd4b46f35c39a78f6defde4ce/cloudcomponents.cdk-dynamodb-seeder-2.4.0.tar.gz",
"platform": null,
"description": "[![cloudcomponents Logo](https://raw.githubusercontent.com/cloudcomponents/cdk-constructs/master/logo.png)](https://github.com/cloudcomponents/cdk-constructs)\n\n# @cloudcomponents/cdk-dynamodb-seeder\n\n[![Build Status](https://github.com/cloudcomponents/cdk-constructs/workflows/Build/badge.svg)](https://github.com/cloudcomponents/cdk-constructs/actions?query=workflow=Build)\n[![cdkdx](https://img.shields.io/badge/buildtool-cdkdx-blue.svg)](https://github.com/hupe1980/cdkdx)\n[![typescript](https://img.shields.io/badge/jsii-typescript-blueviolet.svg)](https://www.npmjs.com/package/@cloudcomponents/cdk-dynamodb-seeder)\n[![python](https://img.shields.io/badge/jsii-python-blueviolet.svg)](https://pypi.org/project/cloudcomponents.cdk-dynamodb-seeder/)\n\n> A seeder for dynamodb tables\n\n## Install\n\nTypeScript/JavaScript:\n\n```bash\nnpm i @cloudcomponents/cdk-dynamodb-seeder\n```\n\nPython:\n\n```bash\npip install cloudcomponents.cdk-dynamodb-seeder\n```\n\n## How to use\n\n```python\nimport * as path from 'path';\nimport { DynamoDBSeeder, Seeds } from '@cloudcomponents/cdk-dynamodb-seeder';\nimport { Stack, StackProps, RemovalPolicy } from 'aws-cdk-lib';\nimport { Table, AttributeType } from 'aws-cdk-lib/aws-dynamodb';\nimport { Bucket } from 'aws-cdk-lib/aws-s3';\nimport { Construct } from 'constructs';\n\nexport class DynamoDBSeederStack extends Stack {\n constructor(scope: Construct, id: string, props: StackProps) {\n super(scope, id, props);\n\n const table = new Table(this, 'Table', {\n partitionKey: {\n name: 'id',\n type: AttributeType.NUMBER,\n },\n removalPolicy: RemovalPolicy.DESTROY,\n });\n\n new DynamoDBSeeder(this, 'JsonFileSeeder', {\n table,\n seeds: Seeds.fromJsonFile(path.join(__dirname, '..', 'seeds.json')),\n });\n\n new DynamoDBSeeder(this, 'InlineSeeder', {\n table,\n seeds: Seeds.fromInline([\n {\n id: 3,\n column: 'foo',\n },\n {\n id: 4,\n column: 'bar',\n },\n ]),\n });\n\n const seedsBucket = Bucket.fromBucketName(\n this,\n 'SeedsBucket',\n 'my-seeds-bucket',\n );\n\n new DynamoDBSeeder(this, 'BucketSeeder', {\n table,\n seeds: Seeds.fromBucket(seedsBucket, 'seeds.json'),\n });\n }\n}\n```\n\n## API Reference\n\nSee [API.md](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-dynamodb-seeder/API.md).\n\n## Example\n\nSee more complete [examples](https://github.com/cloudcomponents/cdk-constructs/tree/master/examples).\n\n## License\n\n[MIT](https://github.com/cloudcomponents/cdk-constructs/tree/master/packages/cdk-dynamodb-seeder/LICENSE)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A seeder for dynamodb tables",
"version": "2.4.0",
"project_urls": {
"Homepage": "https://github.com/cloudcomponents/cdk-constructs",
"Source": "https://github.com/cloudcomponents/cdk-constructs.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4fd55f133fbe343eae3d8927dbdc28885acf6e5e4e77a9abc492241ba0969414",
"md5": "6665ec9ae7e8e74b5a65600fbef1b4ff",
"sha256": "e81f56713c9715d1ce474bc6b588dd76f27718424bb007ea1ee2d2d4c85e4ca9"
},
"downloads": -1,
"filename": "cloudcomponents.cdk_dynamodb_seeder-2.4.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6665ec9ae7e8e74b5a65600fbef1b4ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.8",
"size": 461727,
"upload_time": "2024-05-16T19:33:05",
"upload_time_iso_8601": "2024-05-16T19:33:05.404655Z",
"url": "https://files.pythonhosted.org/packages/4f/d5/5f133fbe343eae3d8927dbdc28885acf6e5e4e77a9abc492241ba0969414/cloudcomponents.cdk_dynamodb_seeder-2.4.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a957f723e7701dd7e8d3cad94b0ed949a4afb66dd4b46f35c39a78f6defde4ce",
"md5": "62f7650e22203c1fc1aa37639e572357",
"sha256": "319f270796d7325858e06fb22b8bd9e53b4226a28aad722668f26751eea2edce"
},
"downloads": -1,
"filename": "cloudcomponents.cdk-dynamodb-seeder-2.4.0.tar.gz",
"has_sig": false,
"md5_digest": "62f7650e22203c1fc1aa37639e572357",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.8",
"size": 463119,
"upload_time": "2024-05-16T19:33:12",
"upload_time_iso_8601": "2024-05-16T19:33:12.044879Z",
"url": "https://files.pythonhosted.org/packages/a9/57/f723e7701dd7e8d3cad94b0ed949a4afb66dd4b46f35c39a78f6defde4ce/cloudcomponents.cdk-dynamodb-seeder-2.4.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-16 19:33:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cloudcomponents",
"github_project": "cdk-constructs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cloudcomponents.cdk-dynamodb-seeder"
}