Our WorkAbout UsOur ApproachThe Journal
Contact »
« Back to the journal
Backend Development + Hosting

Creating an AWS DynamoDB table from the command-line


Mark Biek
Mark Biek

on 7/31/2017

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 aws --profile=via

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, Deleted and Id

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 it!

That’s all there is to it. Now go take a look at all the other neat things you can do with aws dynamodb.

Share to

Related Posts

Backend Development
Migrating from SVN to Git

By: Jason McCreary on 1/30/2014

A look at VIA Studio's recent migration from SVN to Git and how we converted over 100 SVN repositories to Git and improved our development process.

Read More »
RSS In Plain English

By:Jason Clark on 10/29/2008

Even though RSS has been around for ages now, people have a difficult time understanding it’s power and simplicity. This is the best video I’ve seen describing RSS in a non-technical way.

Read More »