My use case is to take a JSON message from SQS body and insert data into DynamoDB Using the lambda function in python. the issue is I am able to read and print the JSON message from SQS queue into cloud watch log but when I try to insert the same JSON in dynamoDB it gives below Error
Invalid type for parameter Item, value: {'name': 2}, type: class 'str', valid types: class 'dict'
Below is the lambda code I am using and an error occurred at line number 12 where I am trying to insert using put_item
import json
import boto3
dynamodb = boto3.resource('dynamodb')
dynamoTable = dynamodb.Table('message')
def lambda_handler(event, context):
for record in event['Records']:
data1 = record["body"]
jsondata1 = json.loads(data1)
print(jsondata1)
dynamoTable.put_item(Item=jsondata1)
However, it is able to print the SQS JSON to cloud watch log as below

jsondata1from your example will be of a string type. Is this the actual code that is giving you the error? - Tommyjsondata1is of type string. Where in your code snippet it isn't. Hence my question is if the sample code you provided is the actual code that is giving you an error. - Tommy