Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

434
Views
AWS - import JSON file to load Dynamo table

I have a json file that I want to use to load my Dynamo table in AWS. In the AWS console, there is only an option to create one record at a time. Not good: )

Essentially my .JSON file is an array of objects which hold the data for each column in the table ie:

{
    "Column1": "Column1 Value",
    "Column2": "Column2 Value",
    "Column3": "Column3 Value",
    "Column4": "Column4 Value",
  },

Is there any way to do this via AWS console and importing my json file, or do I have to use AWS JS SDK to programmatically do this ??

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The answer from E.J. Brennan looks correct, for a single record, but it doesn't answer the original question (which needs to add an array of records).

For this, the command is

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

But, you'll need to make a modified JSON file, like so (note the DynamoDB JSON that specifies data types):

{
    "YourTableName": [
        {   
            "PutRequest": {
                "Item": { 
                    "Column1": { "S": "Column1 Value" },
                    "Column2": { "S": "Column2 Value" },
                    "Column3": { "S": "Column3 Value" },
                    "Column4": { "S": "Column4 Value" },
                }
            }
        },
        {
            "PutRequest": {
                "Item": { 
                    "Column1": { "S": "Column1 Value" },
                    "Column2": { "S": "Column2 Value" },
                    "Column3": { "S": "Column3 Value" },
                    "Column4": { "S": "Column4 Value" },
                }
            }
        }
    ]
}
over 4 years ago · Santiago Trujillo Report

0

You don't need to use the API. You could use the AWS-CLI instead, i.e:

aws dynamodb put-item --table-name MusicCollection --item file://item.json --return-consumed-capacity TOTAL

but you may need to tweak your JSON format a bit.

More examples and documentation here:

https://docs.aws.amazon.com/cli/latest/reference/dynamodb/put-item.html

over 4 years ago · Santiago Trujillo Report

0

I used boto3 in python to load the data

import boto3
import json

dynamodbclient=boto3.resource('dynamodb')
sample_table = dynamodbclient.Table('ec2metadata')

with open('/samplepath/spotec2interruptionevent.json', 'r') as myfile:
    data=myfile.read()

# parse file
obj = json.loads(data)

#instance_id and cluster_id is the Key in dynamodb table 

    response=sample_table.put_item(
                              Item={
                                  'instance_id': instanceId,
                                  'cluster_id': clusterId,
                                  'event':obj

                              }
                              )

Here is a sample for javascript:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Js.02.html#GettingStarted.Js.02.02

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!