{"id":13505549,"url":"https://github.com/elegantdevelopment/aws-cdk-dynamodb-seeder","last_synced_at":"2025-03-30T00:31:06.448Z","repository":{"id":42925646,"uuid":"241672415","full_name":"elegantdevelopment/aws-cdk-dynamodb-seeder","owner":"elegantdevelopment","description":"A simple CDK seeder for DynamoDB","archived":false,"fork":false,"pushed_at":"2023-01-06T02:35:15.000Z","size":785,"stargazers_count":36,"open_issues_count":18,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-04T01:08:45.725Z","etag":null,"topics":["amazon-dynamodb","aws","aws-cdk","cdk-seeder","dynamodb","iac","seeder"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elegantdevelopment.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-19T16:55:19.000Z","updated_at":"2024-11-23T17:25:57.000Z","dependencies_parsed_at":"2023-02-05T03:16:40.057Z","dependency_job_id":null,"html_url":"https://github.com/elegantdevelopment/aws-cdk-dynamodb-seeder","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elegantdevelopment%2Faws-cdk-dynamodb-seeder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elegantdevelopment%2Faws-cdk-dynamodb-seeder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elegantdevelopment%2Faws-cdk-dynamodb-seeder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elegantdevelopment%2Faws-cdk-dynamodb-seeder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elegantdevelopment","download_url":"https://codeload.github.com/elegantdevelopment/aws-cdk-dynamodb-seeder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-dynamodb","aws","aws-cdk","cdk-seeder","dynamodb","iac","seeder"],"created_at":"2024-08-01T00:01:09.732Z","updated_at":"2025-03-30T00:31:01.438Z","avatar_url":"https://github.com/elegantdevelopment.png","language":"TypeScript","funding_links":[],"categories":["Construct Libraries"],"sub_categories":["Databases"],"readme":"# aws-cdk-dynamodb-seeder [![Mentioned in Awesome CDK](https://awesome.re/mentioned-badge.svg)](https://github.com/eladb/awesome-cdk)\n\n![build](https://github.com/elegantdevelopment/aws-cdk-dynamodb-seeder/workflows/build/badge.svg)\n[![codecov](https://codecov.io/gh/elegantdevelopment/aws-cdk-dynamodb-seeder/branch/master/graph/badge.svg)](https://codecov.io/gh/elegantdevelopment/aws-cdk-dynamodb-seeder)\n[![dependencies Status](https://david-dm.org/elegantdevelopment/aws-cdk-dynamodb-seeder/status.svg)](https://david-dm.org/elegantdevelopment/aws-cdk-dynamodb-seeder)\n[![npm](https://img.shields.io/npm/dt/aws-cdk-dynamodb-seeder)](https://www.npmjs.com/package/aws-cdk-dynamodb-seeder)\n\n[![npm version](https://badge.fury.io/js/aws-cdk-dynamodb-seeder.svg)](https://badge.fury.io/js/aws-cdk-dynamodb-seeder)\n[![NuGet version](https://badge.fury.io/nu/ElegantDevelopment.AWSCDKDynamoDBSeeder.svg)](https://badge.fury.io/nu/ElegantDevelopment.AWSCDKDynamoDBSeeder)\n[![PyPI version](https://badge.fury.io/py/aws-cdk-dynamodb-seeder.svg)](https://badge.fury.io/py/aws-cdk-dynamodb-seeder)\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.elegantdevelopment/AWSCDKDynamoDBSeeder?color=brightgreen)](https://repo1.maven.org/maven2/io/github/elegantdevelopment/AWSCDKDynamoDBSeeder/)\n\nA simple CDK JSON seeder for DynamoDB\n\n## Why this package\n\nGlad you asked!\n\nUsing [AWS CDK] for automating infrastructure deployments is an amazing way of integrating the development and operations into one process and one codebase.\n\nHowever, building dev or test environments that come pre-populated with data can be tricky, especially when using [Amazon DynamoDB].\n\n## How do I use it\n\nInstall using your favourite package manager:\n\n```sh\nyarn add aws-cdk-dynamodb-seeder\n```\n\n### Example TypeScript usage\n\n```ts\nimport { Seeder } from 'aws-cdk-dynamodb-seeder';\n...\nconst myTable = new Table(stack, \"MyTable\", {\n    tableName: \"MyTable\",\n    partitionKey: { name: \"Id\", type: AttributeType.STRING },\n});\n...\nnew Seeder(stack, \"MySeeder\", {\n    table: myTable,\n    setup: require(\"./items-to-put.json\"),\n    teardown: require(\"./keys-to-delete.json\"),\n    refreshOnUpdate: true  // runs setup and teardown on every update, default false\n});\n```\n\nFor a more in-depth example, see: [elegantdevelopment/aws-cdk-dynamodb-seeder-examples](https://github.com/elegantdevelopment/aws-cdk-dynamodb-seeder-examples).\n\n### Importing seed data\n\nData passed into `setup` (\"Items\" to put) or `teardown` (\"Keys\" to delete) should be an `array` of objects (that are, in turn, representations of `string` to [AttributeValue] maps).\n\n* `setup` elements should use the format of `params.Item` from [AWS.DynamoDB.DocumentClient.put()]\n* `teardown` elements should use the format of `params.Key` from [AWS.DynamoDB.DocumentClient.delete()]\n\n## Versioning\n\nWe will *attempt* to align the major and minor version of this package with [AWS CDK], but always check our release descriptions for compatibility.\n\nWe currently support [![GitHub package.json dependency version (prod)](https://img.shields.io/github/package-json/dependency-version/elegantdevelopment/aws-cdk-dynamodb-seeder-examples/@aws-cdk/core)](https://github.com/aws/aws-cdk)\n\n## Internals\n\nBehind the scenes we use an [AwsCustomResource] as a representation of the related table's seed state. The custom resource's event handlers invoke a [Function] to perform setup and/or teardown actions.\n\n### Deploying a stack\n\nOn deployment, we write copies of your seed data locally and use a [BucketDeployment] to write it to an S3 [Bucket].\n\nWe then create the handler function and custom resource to field seed requests (the `onCreate` event will immediate fire as the stack deploys, reading the data from the bucket and seeding the table using [AWS.DynamoDB.DocumentClient]).\n\n### Updating a stack\n\nOn a stack update, the `onUpdate` handler is triggered when `refreshOnUpdate` is `true`.\n\nThis will run [AWS.DynamoDB.DocumentClient.delete()] on every teardown \"Key\" followed by [AWS.DynamoDB.DocumentClient.put()] on every setup \"Item\".\n\n### Destroying a stack\n\nWhen the stack is destroyed, the event handler's `onDelete` function will be invoked, providing `teardown` is set.\n\nThis simply runs [AWS.DynamoDB.DocumentClient.delete()] on every teardown \"Key\" before destroying the `Seeder`'s resources.\n\n[aws cdk]: https://aws.amazon.com/cdk\n[amazon dynamodb]: https://aws.amazon.com/dynamodb\n\n[AttributeValue]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html\n[AWS.DynamoDB.DocumentClient]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html\n[AWS.DynamoDB.DocumentClient.put()]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#put-property\n[AWS.DynamoDB.DocumentClient.delete()]: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#delete-property\n\n\u003c!-- Internals --\u003e\n[AwsCustomResource]: https://docs.aws.amazon.com/cdk/api/latest/typescript/api/custom-resources/awscustomresource.html\n[Function]: https://docs.aws.amazon.com/cdk/api/latest/typescript/api/aws-lambda/function.html#aws_lambda_Function\n[Bucket]: https://docs.aws.amazon.com/cdk/api/latest/typescript/api/aws-s3/bucket.html#aws_s3_Bucket\n[BucketDeployment]: https://docs.aws.amazon.com/cdk/api/latest/typescript/api/aws-s3-deployment/bucketdeployment.html#aws_s3_deployment_BucketDeployment\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantdevelopment%2Faws-cdk-dynamodb-seeder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felegantdevelopment%2Faws-cdk-dynamodb-seeder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felegantdevelopment%2Faws-cdk-dynamodb-seeder/lists"}