Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


AWS Lambda Boilerplate

08 Jan 2021 »
import json
import boto3


def lambda_handler(event, context):
    
    # queryParams GET
    qp = event.get("queryStringParameters", {})

    # POST Payload
    data = json.loads(event['body'])



    # CORS Return
    return {
            'statusCode': 200,
            'headers': {
                'Access-Control-Allow-Headers': 'Content-Type',
                'Access-Control-Allow-Origin': 'https://www.example.com',
                'Access-Control-Allow-Methods': 'OPTIONS,POST,GET'
            },
            'body': results,
    }