The table in dynamodb has 2 columns: timeStamp(string) and tableName(string) when trying to insert datetime as string, it fails with this error:
"errorMessage": "Parameter validation failed:\nInvalid type for parameter Item.timeStamp, value: 2022-03-17 16:46:46.510210, type: <class 'str'>, valid types: <class 'dict'>
here is the code snippet:
import json
import boto3
from datetime import datetime as dt
def put_data(timeStamp, tableName):
dynamodb = boto3.client('dynamodb')
#data = json.loads(json.dumps({"timeStamp":timeStamp ,"tableName":tableName}))
#print(data)
response = dynamodb.put_item(TableName='dev-data-migration-state', Item= {"timeStamp":timeStamp ,"tableName":tableName})
print(response)
def lambda_handler(event, context):
put_data(json.loads(json.dumps(str(dt.now()))), 'orders')
i have tried just doing str(dt.now) but that didn't work either.