Arun VM
Arun VM

Reputation: 447

Creating dynamo db tables in local host using json file

I want to create dynamodb tables in localhost I have downloaded my remote dynamodb tables using this script.

https://github.com/bchew/dynamodump

This script I got from this answer over here. How to export an existing dynamo table schema to json?

And I got a local back up of all the tables in my local machine Now I want to create those tables in my dynamodb local system for that reason I am uploading my tables to local DB using this command.

sudo aws  dynamodb create-table --cli-input-json file:///home/evbooth/Desktop/dynamo/table/dynamodump/dump/admin/schema.json --endpoint-url http://localhost:8000

But I am getting an error like this.

Parameter validation failed:
Missing required parameter in input: "AttributeDefinitions"
Missing required parameter in input: "TableName"
Missing required parameter in input: "KeySchema"
Missing required parameter in input: "ProvisionedThroughput"
Unknown parameter in input: "Table", must be one of: AttributeDefinitions, TableName, KeySchema, LocalSecondaryIndexes, GlobalSecondaryIndexes, ProvisionedThroughput, StreamSpecification, SSESpecification

The downloaded json file is like this.

{
  "Table": {
    "TableArn": "arn:aws:dynamodb:us-west-2:xxxx:table/admin", 
    "AttributeDefinitions": [
      {
        "AttributeName": "userid", 
        "AttributeType": "S"
      }
    ], 
    "ProvisionedThroughput": {
      "NumberOfDecreasesToday": 0, 
      "WriteCapacityUnits": 1, 
      "ReadCapacityUnits": 1
    }, 
    "TableSizeBytes": 0, 
    "TableName": "admin", 
    "TableStatus": "ACTIVE", 
    "TableId": "fd21aaab-52fe-4f86-aba6-1cc9a7b17417", 
    "KeySchema": [
      {
        "KeyType": "HASH", 
        "AttributeName": "userid"
      }
    ], 
    "ItemCount": 0, 
    "CreationDateTime": 1403367027.739
  }
}

How can i fix this? I really got annoyed with aws dont have much idea about dynamo db as well

Upvotes: 3

Views: 3910

Answers (2)

stayingcool
stayingcool

Reputation: 2814

I was able to create the table locally in DynamoDB by removing this completely:

"BillingModeSummary": {
    "BillingMode": "PROVISIONED",
    "LastUpdateToPayPerRequestDateTime": 0
  }

Once the table got created I looked at the table meta information, strangely it contains this:

"BillingModeSummary": {
    "BillingMode": "PROVISIONED",
    "LastUpdateToPayPerRequestDateTime": "1970-01-01T00:00:00.000Z"
  }

I went back and tried to create table using the format as shown above. However it failed. Bottomline just remove "BillingModeSummary" and voila the table got created! :-)

Upvotes: 1

Arun VM
Arun VM

Reputation: 447

@wolfson thank you for your suggestion after working some time removing these stuff from the schema helped me to create a table anyway. I removed

1)"Table": {
        "TableArn": "arn:aws:dynamodb:us-west-2:xxxx:table/admin",

2)"NumberOfDecreasesToday": 0,
3), 
        "ItemCount": 0, 
        "CreationDateTime": 1403367027.739
      }
4)"TableSizeBytes": 0,
5) 
        "TableStatus": "ACTIVE", 
        "TableId": "fd21aaab-52fe-4f86-aba6-1cc9a7b17417", 

The resultant json is like but i forced to do this for all the tables and made me to do the create table operation n number of tables.

 {       
        "AttributeDefinitions": [
          {
            "AttributeName": "userid", 
            "AttributeType": "S"
          }
        ], 
        "ProvisionedThroughput": {

          "WriteCapacityUnits": 1, 
          "ReadCapacityUnits": 1
        }, 

        "TableName": "admin",
        "KeySchema": [
          {
            "KeyType": "HASH", 
            "AttributeName": "userid"
          }
        ]
    }

Thank you anyway.

Upvotes: 1

Related Questions