How to parse and iterate to save information in dyanomodb with lamda in python

0 votes

In order to save data from lamda to dynamodb,

import json
import boto3
from botocore.exceptions import ClientError
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('table1')
def lambda_handler(event, context):
        readJson = json.dumps(event)
        parseMe = json.loads(readJson)
        table.put_item(
         Item={
            'webhook_ID': context.aws_request_id,
            'eventType': parseMe['body-json']["eventType"],
            'Name': parseMe['body-json']["Name"],
            'Id': parseMe['body-json']["Id"],
            'ReferenceId': parseMe['body-json']["ReferenceId"],
            'mock': parseMe['body-json']["mock"],
            'description': parseMe['body-json']["description"]
        })
        return {
        'status' : 200,
        'body': json.dumps('data has been received.'),
        'requestID' : context.aws_request_id
        }

The difference is that I want to iterate it because I might need to remove or add properties to the json in the future. This json characteristics is saved in Dynamodb AWS' Table 1. Suggestion?

 

Dec 15, 2022 in AWS by Tejashwini
• 3,820 points
199 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer

How to download S3 Objects With Python and Boto3?

Hi@akhtar, You can download one file from a ...READ MORE

answered Oct 8, 2020 in AWS by MD
• 95,440 points
2,427 views
+1 vote
1 answer

How to authenticate session in application running on Beanstalk with boto3

The recommended way of managing credentials used ...READ MORE

answered Aug 28, 2018 in AWS by Priyaj
• 58,090 points
1,418 views
+1 vote
1 answer
0 votes
2 answers

How to skip headers when reading a CSV file in S3 and creating a table in AWS Athena?

Thanks for the answer. This should be clear ...READ MORE

answered Aug 14, 2019 in AWS by athenauserz
11,226 views
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 58,090 points
9,591 views
0 votes
1 answer

Send a file in post method in aws lambda?

Looks like you're already using request module. in this case ...READ MORE

answered Oct 5, 2018 in AWS by Priyaj
• 58,090 points
3,845 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,810 points
2,582 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP