I'm new to coding and trying to create a modifiable database using boto3, python 2.7, dynamodb and aws lambda. It's unclear to me how to characterize the event parameters for some expected JSON (possibly dict) input. Do you need to create some sort of Key in another area. I'm able to hard code some data and pass the information to dynamodb, but for a generic type of update_item/put_item, have not been successful.
import json
import boto3
# Get service resource
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('MyTable')
def lambda_handler(event,context):
response = table.put_item(
Item={
json.dumps(event)
}
)
return{
'statusCode': 200,
'body': {}
}
}
The error is:
ParamValidationError: Parameter validation failed:
Invalid type for parameter Item, value: set(['{"key3": "value3", "key2": "value2", "key1": "value1"}']), type: <type 'set'>, valid types: <type 'dict'>