cloudcomponents.cdk-dynamodb-seeder


Namecloudcomponents.cdk-dynamodb-seeder JSON
Version 2.3.0 PyPI version JSON
download
home_pagehttps://github.com/cloudcomponents/cdk-constructs
SummaryA seeder for dynamodb tables
upload_time2024-04-17 18:36:08
maintainerNone
docs_urlNone
authorhupe1980
requires_python~=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![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/bf/ed/2fe1346d0f95ec81c9c46441540b6c3c62a4b1edc146af21ddaea8137d9e/cloudcomponents.cdk-dynamodb-seeder-2.3.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.3.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": "752caac8e955762813329471f31aa4c8fff3af5b9017c4633a125d5539c36b69",
                "md5": "e5832336a6481dd867ba7edb4b744913",
                "sha256": "def7723005e214963b812df45c5af9f0445cb8c5b3a4ae71cc2c263599a59f33"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk_dynamodb_seeder-2.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e5832336a6481dd867ba7edb4b744913",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.8",
            "size": 1661484,
            "upload_time": "2024-04-17T18:36:02",
            "upload_time_iso_8601": "2024-04-17T18:36:02.083647Z",
            "url": "https://files.pythonhosted.org/packages/75/2c/aac8e955762813329471f31aa4c8fff3af5b9017c4633a125d5539c36b69/cloudcomponents.cdk_dynamodb_seeder-2.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfed2fe1346d0f95ec81c9c46441540b6c3c62a4b1edc146af21ddaea8137d9e",
                "md5": "4fa598a4ea0968b2ffd90e2e27a9630d",
                "sha256": "7a170b164bb4347ac0f002404691cc7f4f91b9f234c031aae8c8d184fb226b95"
            },
            "downloads": -1,
            "filename": "cloudcomponents.cdk-dynamodb-seeder-2.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4fa598a4ea0968b2ffd90e2e27a9630d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.8",
            "size": 1662826,
            "upload_time": "2024-04-17T18:36:08",
            "upload_time_iso_8601": "2024-04-17T18:36:08.506857Z",
            "url": "https://files.pythonhosted.org/packages/bf/ed/2fe1346d0f95ec81c9c46441540b6c3c62a4b1edc146af21ddaea8137d9e/cloudcomponents.cdk-dynamodb-seeder-2.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 18:36:08",
    "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"
}
        
Elapsed time: 0.24405s