Skip to content

This project shows how to deploy a Python 3.12 AWS Lambda function using Docker and the Serverless Framework on Windows 11. It uses Docker Buildx for Linux/AMD64 compatibility, packages code with the Lambda base image, and exposes it via API Gateway, providing a repeatable workflow for serverless deployments.

Notifications You must be signed in to change notification settings

Shorya22/AWS-Serverless-Deployment

Repository files navigation

AWS Serverless Deployment (Python 3.12 + Docker + Serverless Framework)

This project provides a Standard Operating Procedure (SOP) for deploying a Python 3.12 AWS Lambda function using Docker, the Serverless Framework, and API Gateway on a Windows 11 (x86_64) machine.
It also includes solutions for common issues such as image manifest incompatibility when building Lambda Docker images.


📌 Document Purpose

Provide a repeatable guide for deploying the my-app-test serverless application with Dockerized AWS Lambda using the Serverless Framework.


⚡ Prerequisites

Make sure you have the following installed and configured:


📂 Project Structure

D:\AWS\app2
├── Dockerfile
├── main.py
├── requirements.txt
└── serverless.yml

📝 Files Overview

main.py

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": "Hello from Docker Lambda!"
    }

requirements.txt

# Add dependencies here (optional)

Dockerfile

FROM public.ecr.aws/lambda/python:3.12 
WORKDIR ${LAMBDA_TASK_ROOT}
COPY requirements.txt .
RUN pip install --upgrade pip &&     pip install --no-cache-dir --prefer-binary -r requirements.txt
COPY main.py .
CMD ["main.lambda_handler"]

serverless.yml

service: my-app-test

provider:
  name: aws
  runtime: provided.al2
  region: us-east-1
  timeout: 29
  memorySize: 2048
  ecr:
    images:
      app-lambda-test:
        path: .
        platform: linux/amd64
        provenance: false

functions:
  chatbot:
    image:
      name: app-lambda-test
    architecture: x86_64
    events:
      - http:
          path: chat
          method: post
    environment:
      GROQ_API_KEY: ${env:GROQ_API_KEY}

🐳 Docker Setup

Initialize Docker Buildx:

docker buildx create --use
docker buildx inspect --bootstrap

🚀 Deployment

Deploy the Lambda function:

serverless deploy

Remove all deployed resources:

serverless remove

✅ Summary

This project demonstrates end-to-end serverless deployment of a Python 3.12 Lambda function using Docker containers and the Serverless Framework on AWS, ensuring compatibility on Windows (x86_64).


About

This project shows how to deploy a Python 3.12 AWS Lambda function using Docker and the Serverless Framework on Windows 11. It uses Docker Buildx for Linux/AMD64 compatibility, packages code with the Lambda base image, and exposes it via API Gateway, providing a repeatable workflow for serverless deployments.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages