Home > Software design >  AWS Printing DynamoDB Table Via CLI
AWS Printing DynamoDB Table Via CLI

Time:11-21

I'm trying to find the right command to use in the CLI to print the contents of a table within DynamoDB.

I've tried using the following command but it gives me a "parameter validation failed" error.

`

aws dynamodb get-item \
    --table-name Traffic \
    --key file://traffic.json \
    --return-consumed-capacity TOTAL

`

The AWS website is giving me a 403 error, at the moment, so I can't search for the solution through the official site.

CodePudding user response:

To get all items in a table, use a scan operation, not a get item operation. This basic scan operation works fine with the CLI:

aws dynamodb scan --table-name Work

enter image description here

You can find all valid options here:

https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html

CodePudding user response:

You can run the Scan API to output how the table looks in DynamoDB JSON format.

aws dynamodb scan \
--table-name test \
--output text

If you have a list of keys to fetch in your traffic.json file then you should use batch-get-item.

If it's a single item you need then please share the contents of traffic.json file.

  • Related