9

I was wondering if its possible to create a dynamodb table from the table definition json itself? I've looked into the aws cli tool and I couldnt find any way of doing this. Just wondering if it's possible.

aws dynamodb create-table file://tabledenifision.json

Thanks!

webber
  • 1,686
  • 5
  • 23
  • 51
  • 1
    What do you mean you "had no luck"? Did you get an error, and what did the error say? What is inside the `tabledenifision.json` file? – kurtzbot Aug 20 '14 at 16:22
  • 1
    Sorry about that. I meant I couldnt find any way of doing it. There's no command to read in an entire table schema as json – webber Aug 20 '14 at 21:01
  • The first two searches on Google for "aws create table json" seem really promising, both directly from AWS itself. [1](http://docs.aws.amazon.com/cli/latest/userguide/shorthand-syntax.html) [2](http://docs.aws.amazon.com/cli/latest/reference/dynamodb/create-table.html). Do neither of these accomplish what you want? – kurtzbot Aug 21 '14 at 01:28
  • No, neither of the links accomplish it. – Amit Naidu Jun 18 '19 at 18:28
  • 1
    If you don't know what to put inside `tabledefinition.json` file, you might use https://dynobase.dev/dynamodb-table-schema-design-tool/. It helps me a lot. – Rafal Wiliński May 06 '20 at 08:00
  • Additional answers on this duplicate question: https://stackoverflow.com/questions/42100210/how-to-export-an-existing-dynamo-table-schema-to-json#answer-67695947 – Curtis Yallop May 27 '21 at 16:55

1 Answers1

34

I found your unanswered question today, and kept looking until I found an answer. Probably too late for you but may help others.

aws dynamodb create-table --cli-input-json file://tabledefinition.json

This command expects a json object in the file in the format outlined by the following command:

aws dynamodb create-table --generate-cli-skeleton

This approach seems to work with many aws commands.

Keith Branton
  • 341
  • 3
  • 5
  • is it possible to reverse-engineer the json file from an existing dynamodb table? – Anthony Kong Nov 04 '20 at 13:59
  • @AnthonyKong Yes, use aws dynamo describe-table --table-name existing_table_name and the output is JSON `Table` property is in the same format – Luke Sep 17 '21 at 11:27