{"id":13990637,"url":"https://github.com/buildertools/dynamodb-snapshot-containers","last_synced_at":"2026-01-28T22:40:58.080Z","repository":{"id":75075270,"uuid":"91202322","full_name":"buildertools/dynamodb-snapshot-containers","owner":"buildertools","description":"This project both wraps the DynamoDB devkit and provides a mechanism for capturing snapshots that can be attached to dependent services at test time to launch from well known states.","archived":false,"fork":false,"pushed_at":"2017-06-21T16:58:46.000Z","size":16604,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-09T13:17:35.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/buildertools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-05-13T20:56:43.000Z","updated_at":"2018-08-01T06:40:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2bcbea1-cd5c-4b36-9cd4-6481854abdac","html_url":"https://github.com/buildertools/dynamodb-snapshot-containers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildertools%2Fdynamodb-snapshot-containers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildertools%2Fdynamodb-snapshot-containers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildertools%2Fdynamodb-snapshot-containers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buildertools%2Fdynamodb-snapshot-containers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buildertools","download_url":"https://codeload.github.com/buildertools/dynamodb-snapshot-containers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227098920,"owners_count":17730670,"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":[],"created_at":"2024-08-09T13:03:02.803Z","updated_at":"2026-01-28T22:40:58.026Z","avatar_url":"https://github.com/buildertools.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# DynamoDB-Snapshot-Containers\n\nFunctional testing a stateful system is challenging because your tests typically mutate the state of the system under test. This leads to all sorts of \"dirty state\" problems where tests fail because the system under test was not started from a known state. The matter is made much worse when your software leverages managed services or proprietary database technology like DynamoDB. I love DynamoDB, but introducing a network dependency on development environments and functional tests is a bad idea. AWS released a [local DynamoDB devkit](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html) sometime ago. This project both wraps that [DynamoDB devkit in a container](https://hub.docker.com/buildertools/dynamodb-local) and provides a mechanism for capturing snapshots that can be attached to dependent services at test time to launch from well known states.\n\n## Dependencies\n\n1. A POSIX shell\n2. Docker (for Linux containers)\n\n## Getting Started\n\nIf you're familiar with the AWS CLI then you can write a script to build up the state your tests require. This is the provided example-script.sh:\n\n    #!/bin/sh\n    # Add a known table\n    aws dynamodb create-table \\\n        --endpoint-url http://localhost:8000 \\\n        --region us-west-2 \\\n        --table-name acl \\\n        --attribute-definitions AttributeName=customer,AttributeType=S AttributeName=resource,AttributeType=S \\\n        --key-schema AttributeName=customer,KeyType=HASH AttributeName=resource,KeyType=RANGE \\\n        --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5\n    \n    # Add some known state\n    aws dynamodb put-item \\\n        --endpoint-url http://localhost:8000 \\\n        --region us-west-2 \\\n        --table-name acl \\\n        --item '{\"customer\": {\"S\": \"Bob\"}, \"resource\": {\"S\": \"ACCOUNT-1234\"}, \"access\": {\"S\": \"Admin\"}}'\n    aws dynamodb put-item \\\n        --endpoint-url http://localhost:8000 \\\n        --region us-west-2 \\\n        --table-name acl \\\n        --item '{\"customer\": {\"S\": \"Bob\"}, \"resource\": {\"S\": \"ACCOUNT-4321\"}, \"access\": {\"S\": \"User\"}}'\n    aws dynamodb put-item \\\n        --endpoint-url http://localhost:8000 \\\n        --region us-west-2 \\\n        --table-name acl \\\n        --item '{\"customer\": {\"S\": \"Ray\"}, \"resource\": {\"S\": \"ACCOUNT-4321\"}, \"access\": {\"S\": \"Admin\"}}'\n\nWith your state described as a script you can use the ````build-snap.sh```` script to write that state to a DynamoDB container and save that state for use later. This command uses ````example-script.sh```` to build the database state and store the results in a Docker repository named: ````myproject/db-test-suite:acl-case2````. The image will be tagged with an author and a message provided by the second and third arguments.\n\n    ./build-snap.sh example-script.sh awesomeproject/db-test-suite:acl-case2 \"jeff@allingeek.com\" \"ACL project testing: 2 admin, 1 user\"\n\n## Using the Snapshots\n\nThe snapshots that are created run on port 8000 inside containers. If you want to use the AWS CLI to explore one and verify that it works run:\n\n    docker run -d -p 8000:8000 --name dynamo-example \u003cSNAPSHOT_REPOSITORY\u003e\n    aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-west-2\n\nIf your AWS CLI environment is configured correctly the ````aws```` command will list the tables that you created in your script.\n\nThese snapshots are much more interesting when you use them as service dependencies in CI/CD pipelines for functional testing.\n\n## LICENSE\n\nThis repository contains a vendored copy of [https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz](https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz). That vendored copy has not been modified in any form. Any an all licences associated with that source and its dependencies are included. This project makes no copyright or license assertions on that material. All source outside of the ````dynamodb_local_latest```` directory is licensed under MIT (See [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildertools%2Fdynamodb-snapshot-containers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuildertools%2Fdynamodb-snapshot-containers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuildertools%2Fdynamodb-snapshot-containers/lists"}