Skip to content

05 Lambda Layers

DodaTech 1 min read

title: Lambda Layers for Serverless APIs weight: 15 date: 2026-06-28 lastmod: 2026-06-28 description: Use AWS Lambda layers to share common dependencies like Python packages, runtime extensions, and custom utilities across multiple serverless functions for reduced deployment size. tags: [api-development, serverless]


AWS Lambda layers package shared dependencies (libraries, runtime extensions, custom utilities) separately from function code, reducing deployment package size and enabling consistent dependency versions across functions.

```bash
# Create a layer with Python dependencies
mkdir -p python_layer/python
pip install requests pydantic boto3 -t python_layer/python/

# Zip the layer
cd python_layer && zip -r ../requests-layer.zip python/

# Publish the layer
aws lambda publish-layer-version \
  --layer-name python-requests \
  --description "Python requests library" \
  --zip-file fileb://requests-layer.zip \
  --compatible-runtimes python3.11 python3.10

# Attach to function
aws lambda update-function-configuration \
  --function-name my-function \
  --layers arn:aws:lambda:us-east-1:123456789012:layer:python-requests:1

What's Next

Now learn about Lambda environment in Building Serverless APIs.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro