Export data from DynamoDB

后端 未结 17 1877
离开以前
离开以前 2020-12-13 04:02

Is it possible to export data from DynamoDB table in some format?

The concrete use case is that I want to export data from my production dynamodb database and import

17条回答
  •  不知归路
    2020-12-13 04:38

    I extend Valy dia solution to allow all the process of exporting with only aws-cli | jq

    aws dynamodb scan --max-items 3 --table-name  \
    | jq '{"": [.Items[] | {PutRequest: {Item: .}}]}' > data.json
    
    aws dynamodb describe-table --table-name  > describe.json | jq ' .Table | {"TableName": .TableName, "KeySchema": .KeySchema, "AttributeDefinitions": .AttributeDefinitions,  "ProvisionedThroughput": {
          "ReadCapacityUnits": 5,
          "WriteCapacityUnits": 5
    }}' > table-definition.json
    
    aws dynamodb create-table --cli-input-json file://table-definition.json  --endpoint-url http://localhost:8000 --region us-east-1
    
    aws dynamodb batch-write-item --request-items file://data.json --endpoint-url http://localhost:8000
    
    aws dynamodb scan --table-name  --endpoint-url http://localhost:8000
    

提交回复
热议问题