Vihung
Vihung

Reputation: 13397

How do I export data (tables and data) from AWS DynamoDB and import into a local DynamoDB?

I would like to create an isolated local environment (running on linux) for development and testing.

How can I export data (~10 tables and ~few hundred items of data) from AWS DynamoDB ind import into a local DynamoDB instance?

Upvotes: 8

Views: 10338

Answers (3)

Chris McLaughlin
Chris McLaughlin

Reputation: 340

You can use dynamodump.

First export from AWS to your local machine:

python dynamodump.py -m backup -r REGION_NAME -s TABLE_NAME

Next import to DynamoDB Local:

python dynamodump.py -m restore -r local -s TABLE_NAME --host localhost --port 8000 --accessKey a --secretKey a

Finally verify the new local tables:

aws dynamodb list-tables --endpoint-url http://localhost:8000

Important: If your provisioned read / write capacity on AWS is on-demand, you must manually change the ReadCapacityUnits and WriteCapacityUnits values in the saved schema.json file from step 1 from '0' to '1' to avoid the following error: Table read and write throughput must be at least 1, and cannot be null

Upvotes: 4

F_SO_K
F_SO_K

Reputation: 14799

I've not tried this, but you should be able to use the CLI.

First extract the data into local JSON files

aws dynamodb scan --table-name MYLIVETABLE --output json > pathtofile/MYLIVETABLE.json

And then load that data into your local DynamoDB instance

aws dynamodb batch-write-item --table-name MYLOCALTABLE --request-items file://pathtofile/MYLIVETABLE.json --endpoint-url http://localhost:8000

Upvotes: 1

Krunal Barot
Krunal Barot

Reputation: 932

AWS do provide the local version for dynamoDB. More details below:https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html

create the local copy as mentioned above and transfer it in another local DynamoDB instance ..

Upvotes: -3

Related Questions