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?