Skip to content

AWS Lambda

Serverless Framework Configuration Example

To deploy a Lambda function via the Serverless Framework, configure a serverless.yml file:

service: my-python-lambda
frameworkVersion: "3"

provider:
  name: aws
  runtime: python3.13
  region: us-east-1

functions:
  hello:
    handler: handler.hello
    events:
      - httpApi:
          path: /hello
          method: get

Deploy with:

sls deploy

Python Lambda Handler Example

An example API Gateway trigger handler handler.py:

import json


def hello(event, context):
    body = {
        "message": "Go Serverless v3.0! Your function executed successfully!",
        "input": event,
    }

    response = {"statusCode": 200, "body": json.dumps(body)}

    return response