bsmsapp/terraform/resources/lambda/lambdaUpdateAPI/lambda_handler.py

25 lines
492 B
Python

import json
import boto3
def main(event, context):
payload = event
body = payload["body"]
body = body.replace('\n', '')
query = json.loads(body)
client = boto3.resource('dynamodb', region_name="us-east-1")
table = client.Table("AWSDynamoDB-g3")
table.put_item(Item=query)
resp = {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
},
"body": "El elemento fue agregado."
}
return resp