Set up the AWS CLI on Windows

Theoretically you can install the AWS CLI1 to import JSON files to DynamoDB.

Once you install this, you’ll want to add it to your path.

To connect, do this:

aws configure

To fill out the prompts, you’ll need to create a username/password.2. Then find the region name3.

To use DynamoDB, create a table, then create a policy with rights to add/select from the table4.

The policy will look like this:

 "Version": "2012-10-17",
 "Statement": [
   "Effect": "Allow",
   "Action": [
   "Resource": [
   "Condition": {
    "ForAllValues:StringEquals": {
     "dynamodb:LeadingKeys": [

You can save this in the policy editor5, attach policy to the user you made earlier 6. Alternately, there is a permission called AmazonDynamoDBFullAccess that you can add.

Then, this will work:

aws dynamodb list-tables

Theoretically this should work:

aws dynamodb batch-write-item --request-items file://1.json

However, the AWS tool seems to suffer from the disastrous Python unicode problems:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 3747-3748: ordinal not in range(128)

I went through a few dozen blog posts / Github tickets, and nothing solved it.

Rather, I found that once you get this far, it’s worth just writing Python scripts to upload data:

from __future__ import print_function
import boto3
import json
import decimal

# endpoint_url="http://localhost:8000"
dynamodb = boto3.resource('dynamodb', region_name='us-east-1')

table = dynamodb.Table('talks')

with open("d:\\projects\\image-annotation\\data\\talks\\json\\1\\1.json") as json_file:
  row = json.load(json_file, parse_float = decimal.Decimal)
      'id_i': str(row['id_i'])
  1. []
  2. []
  3. []
  4. []
  5. []
  6. []