Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export and import DynamoDB data across environments
#!/bin/sh
SOURCE_TABLE=xxx-mydata-accp
TARGET_TABLE=xxx-mydata-prod
AWS_PROFILE=default
AWS_REGION=ap-southeast-2
# Step 1 - export and transform
aws --profile=$AWS_PROFILE \
--region=$AWS_REGION \
dynamodb scan \
--table-name $SOURCE_TABLE \
| jq '{"$TARGET_TABLE": [.Items[] | {PutRequest: {Item: .}}]}' > export.json
# Step 2 - import data
aws --profile=$AWS_PROFILE \
--region=$AWS_REGION \
dynamodb batch-write-item \
--request-items export.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.