One of the great things about the AWS command-line tool is that you can do pretty much any AWS operation with it.
For today’s example, we’re going to show you how to easily create a new DynamoDB table.
Step 1: Set Up Your AWS CLI Credentials
Create the file
~/.aws/config and add a block like the following:
This will let you run authenticated AWS commands with
Step 2: Create the Table JSON File
The easiest way to create a new table is by passing a JSON file with the table schema to the AWS CLI tool.
You can read the create-table documentation to get an idea of all the available options.
You can also use the following command to view the schema of an existing table if you’re going to create something similar:
aws --profile=via dynamodb describe-table --table-name=MyTable
(Note: You won’t be able to use the exact output above to create a new table. First, you’ll have to remove any “Arn”, “Size”, “NumberOfDecreasesToday”, “Count”, and date/time attributes.)
Here’s a sample schema which creates the table
Items with two attributes,
Step 3: Create the Table
Once you have the JSON schema, creating the new table is super simple.
Assuming your JSON file is called Items.json, just run the following command:
aws --profile=via dynamodb create-table --cli-input-json file://Items.json
That’s all there is to it. Now go take a look at all the other neat things you can do with