I'm working on an open source CLI / Python SDK called LaunchFlow that sets up the exact automation you described! All you need to do is supply a requirements.txt for the Python dependencies, and the tool will zip up your local workspace + Python dependencies and release it to your Lambda function.

The code looks like this:

import launchflow as lf
import numpy as np


def handler(event, context):
    result = np.random.randint(0, 100)
    return {
        "statusCode": 200,
        "body": f"Random Number: {result}",
    }


api = lf.aws.LambdaService(
    name="my-lambda-api",
    handler=handler,
    runtime=lf.aws.lambda_service.PythonRuntime(
        requirements_txt_path="requirements.txt"
    ),
)

LambdaService Docs link

Just pip install launchflow[aws] + lf deploy to set up the automation with your local AWS credentials.

If you'd rather create your own automation, you could look at the LambdaService source code to see how we automate the Lambda build / release steps with boto3.

Answer from Joshua Tanke on Stack Overflow
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python
Building Lambda functions with Python - AWS Lambda
In the DEPLOY section, choose Deploy to update your function's code. Then, to run your code, choose Create test event in the TEST EVENTS section. Your Lambda function comes with a CloudWatch Logs log group. The function runtime sends details about each invocation to CloudWatch Logs.
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › deploy python lambda functions with container images
Deploy Python Lambda functions with container images - AWS Lambda
To complete the steps in this section, you must have the following: ... Create a directory for the project, and then switch to that directory. ... Create a new file called lambda_function.py. You can add the following sample function code to the file for testing, or use your own. import sys ...
Discussions

amazon web services - How to package and deploy AWS python lambda functions automatically - Stack Overflow
I have created a AWS python lambda using some modules like kafka, numpy, boto3 etc. Boto3 is already provided by AWS environment. For Numpy, I am using AWS predefined layer. After deploying it as .zip file with kafka and other modules, the size is around 14 MB and AWS UI wont show the code saying More on stackoverflow.com
🌐 stackoverflow.com
amazon web services - How do add python libraries to AWS Lambda? - Stack Overflow
AWSTemplateFormatVersion: '2010-09-09' ... Runtime: python3.8 CodeUri: . Description: "This is my SAM function" MemorySize: 128 Timeout: 3 ... sam build --debug --template-file template.yaml sam package --s3-bucket your_s3_bucket --s3-prefix sam-deployments \ --output-template-file packaged-template.yaml sam deploy -t packaged-template.yaml --stack-name your_stack_name \ --region your_aws_region --capabilities CAPABILITY_IAM · A common folder structure for a Lambda project using ... More on stackoverflow.com
🌐 stackoverflow.com
What's the fastest way to package requirements for a Lambda Function?
AWS SAM with sync. https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-sync.html More on reddit.com
🌐 r/aws
60
26
January 5, 2024
How to host Rust web servers?
That’s what Gitops is for. You add a dependency bot that automatically updates your base image and publish the resulting up-to-date image if it works. More on reddit.com
🌐 r/rust
29
10
June 26, 2025
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › working with .zip file archives for python lambda functions
Working with .zip file archives for Python Lambda functions - AWS Lambda
In your CloudFormation template, the AWS::Lambda::Function resource specifies your Lambda function. In this resource, set the following properties to create a function using a .zip file archive: ... You can declare simple functions written in Python or Node.js inline in an CloudFormation template. Because the code is embedded in YAML or JSON, you can't add any external dependenices to your deployment package.
🌐
Digital Cloud
digitalcloud.training › home › aws tutorials › deploying python functions to aws lambda
Deploying Python functions to AWS Lambda
January 1, 2026 - You will need to have the requests library installed. You can install it using pip by running the command pip install requests in your terminal or command prompt. An IDE or text editor like PyCharm, Visual Studio Code, or IDLE
🌐
Simon Willison
til.simonwillison.net › awslambda › asgi-mangum
Deploying Python web apps as AWS Lambda functions | Simon Willison’s TILs
The finished function.zip is 7.1MB. Time to deploy it: aws lambda update-function-code \ --function-name lambda-python-hello-world \ --zip-file fileb://function.zip
Top answer
1 of 2
1

I'm working on an open source CLI / Python SDK called LaunchFlow that sets up the exact automation you described! All you need to do is supply a requirements.txt for the Python dependencies, and the tool will zip up your local workspace + Python dependencies and release it to your Lambda function.

The code looks like this:

import launchflow as lf
import numpy as np


def handler(event, context):
    result = np.random.randint(0, 100)
    return {
        "statusCode": 200,
        "body": f"Random Number: {result}",
    }


api = lf.aws.LambdaService(
    name="my-lambda-api",
    handler=handler,
    runtime=lf.aws.lambda_service.PythonRuntime(
        requirements_txt_path="requirements.txt"
    ),
)

LambdaService Docs link

Just pip install launchflow[aws] + lf deploy to set up the automation with your local AWS credentials.

If you'd rather create your own automation, you could look at the LambdaService source code to see how we automate the Lambda build / release steps with boto3.

2 of 2
0

For the git piece: I'd recommend just checking in your main python file and a related set of requirements.txt files.

The two paths that I've used for easier Lambda deployments are Serverless and Terraform. I'll outline them briefly (there's also Amazon's CDK but I am less familiar with it).

  • Serverless is basically a wrapper around Amazon's Infrastructure as Code tool (CloudFormation); either a set of JSON or YAML that define your Lambda and any associated resources. Here's a decent example of your setup i.e. a git tracked handler.py, a requirements.txt file and a serverless.yml to deploy the lambda.
  • For Terraform, it's a more general purpose Infrastructure as Code tool that has plugins for each major cloud provider. The best example I could dig up was a simplified repo

Terraform's main advantage is for change tracking in a more generic way, but Serverless I think is simpler if you're not familiar with either one. (Serverless uses CloudFormation stacks for tracking changes, which are a bit funkier than Terraform's state management).

Most ideally; you'd want to have these things run in a pipeline on merge, so that your lamda is updated with new code changes after a code review and merge into a git repo. It might look like:

  1. Someone submits a Pull Request to your Git repository
  2. The request is reviewed/ merged
  3. On before/merge, some tests run to verify the code
  4. You run the serverless/terraform deploy to update the lambda
  5. Do some final, end to end verification on the new deployment

Let me know if you need me to clarify anything!

🌐
TheServerSide
theserverside.com › blog › Coffee-Talk-Java-News-Stories-and-Opinions › create-python-aws-lambda-function-hello-world-tutorial-serverless-how-to-example
Create your first Python AWS Lambda function in minutes
Log into the AWS console and navigate to the Lambda dashboard. Click the orange Create Function button. Specify the function’s name and the Python version (Python 3.10 is recommended).
Find elsewhere
🌐
Medium
ystatit.medium.com › create-and-upload-your-own-python-code-to-aws-lambda-8acb61712fd9
Create and Upload Your Own Python Code to AWS Lambda | by Yst@IT | Medium
December 23, 2019 - ... Next, use CLI to upload your zip file to Lambda. Elements you need for the commend: ... If everything is setup correctly, you will see response from AWS and right away you would see Lambda function is created in the Lambda console.
🌐
Medium
medium.com › swlh › tips-to-deploy-python-package-on-aws-lambda-fbf4bed4dc87
Some tips to deploy a Python package on AWS Lambda | by Matyas Amrouche | The Startup | Medium
June 16, 2020 - When deploying a python package (< few MB) on AWS Lambda with external libraries (like numpy, pandas…), you must put all these libs in the lambda folder you want to deploy. Then zip all the files it contains and finally deploy the zip file.
🌐
Medium
medium.com › full-stack-engineer › the-simplest-aws-lambda-in-python-7656bc067a3a
How Do I Deploy a Simple Python Lambda in AWS Using the CDK? | Full Stack Wizardry
April 19, 2025 - Learn how to set up the AWS infrastructure to support a Python lambda using CDK, and how to write a basic "Hello Lambda" script, deploy it, and destroy it.
🌐
PyPI
pypi.org › project › python-lambda
python-lambda · PyPI
When you're ready to deploy your code to Lambda simply run: ... The deploy script will evaluate your virtualenv and identify your project dependencies. It will package these up along with your handler function to a zip file that it then uploads ...
      » pip install python-lambda
    
Published   Jan 05, 2021
Version   11.8.0
🌐
GitHub
github.com › marketplace › actions › deploy-lambda-python
Deploy Lambda Python - GitHub Marketplace
A Github Action to deploy AWS Lambda functions written in Python with their dependencies in a separate layer. For now, only works with Python 3.6. PRs welcome. Deploys everything in the repo as code to the Lambda function, and installs/zips/deploys ...
🌐
Shellnetsecurity
blog.shellnetsecurity.com › posts › how to use terraform to deploy a python script to aws lambda
How to Use Terraform to Deploy a Python Script to AWS Lambda | My Battles With Technology
April 20, 2023 - Deploy Python scripts to AWS Lambda using Terraform. Bundle dependencies with layers, configure API Gateway, and automate infrastructure as code.
🌐
Medium
medium.com › @manzurulhoque › deploy-aws-lambda-python-function-with-aws-cli-27f60e471ae5
Deploy AWS lambda python function with aws-cli | by Manjurul Hoque Rumi | Medium
April 1, 2023 - To deploy our lambda code, we need the Amazon Resource Name (ARN) of the role that we created in our last step. ... aws lambda create-function \ --function-name basic-lambda \ --runtime python3.8 \ --zip-file fileb://main.zip \ --handler ...
🌐
Medium
medium.com › @souyama › deploying-python-to-aws-lambda-with-dependencies-e6cae67a822e
Deploying Python code to AWS Lambda with dependencies | by Souyama | Medium
May 12, 2023 - Directly deploying it lambda will not be possible and we need to provision a S3 bucket for this to be done anyway. Just so that we don’t we don’t loose access to our code or hugely impact our startup time, we will be pushing this into a layer.
Top answer
1 of 4
4

To use any 3rd party library in lambda you can use a lambda layer.

install the dependency using following command

pip3 install <your_package> -t .

zip the package

zip -r your_pkg_layer.zip .

create the layer in aws and upload the zip, after that add the layer to your lambda function

you can follow this blog in medium.

2 of 4
2

I recommend that you look at AWS SAM

AWS SAM is an extension of CloudFormation that simplifies the development of serverless applications.

To deploy a AWS Lambda function using AWS Serverless Application Model (SAM), you need to follow these steps:

  • Create a SAM template: This is a YAML file that defines the AWS resources you want to deploy, including the Lambda function and its dependencies.

  • Package the function: Package the function code and any dependencies into a .zip file. (For this you'll need a requirements.txt file with all the dependencies your code needs)

  • Deploy the function: Use the AWS CLI command deploy to deploy the SAM template and function code to AWS. The command will create or update a CloudFormation stack, which creates or updates the specified AWS resources.

Example SAM template:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: main.handler
      Runtime: python3.8
      CodeUri: .
      Description: "This is my SAM function"
      MemorySize: 128
      Timeout: 3

Example AWS CLI command:

sam build --debug --template-file template.yaml
sam package --s3-bucket your_s3_bucket --s3-prefix sam-deployments \
                  --output-template-file packaged-template.yaml
sam deploy -t packaged-template.yaml --stack-name your_stack_name \
          --region your_aws_region --capabilities CAPABILITY_IAM 

A common folder structure for a Lambda project using AWS Serverless Application Model (SAM) would look something like this:

my-lambda-project/
├── main.py # Lambda function code
├── template.yaml # SAM template
├── requirements.txt # Python dependencies
🌐
Reddit
reddit.com › r/aws › what's the fastest way to package requirements for a lambda function?
r/aws on Reddit: What's the fastest way to package requirements for a Lambda Function?
January 5, 2024 -

I am dynamically creating lambda functions based on different requirements.txt and code supplied.

sometimes the requirements.txt changes and sometimes the code supplied changes.

currently i have a disguisting process of creating a venv then pip installing everything to a folder, zipping it up and send it to s3 and providing that s3 object zip file to my lambda for creation.

its really gross, especially if i want to modify the code i download it, unzip it, then compare and then zip it again then merge.

there HAS to be a better way, how are folks doing it?

EDIT: Wrote a quick script to test containerizing the code and useing ECS then sending the image url to lambda: https://github.com/esteininger/aws-docker-ecr-lambda/blob/main/ecr.py

unfortunately it's still much slower than zipping locally.

🌐
GitHub
github.com › ncvc › lambda-deploy
GitHub - ncvc/lambda-deploy: Simple script to deploy Python code to AWS Lambda · GitHub
In deploy.py, change MODULE_DIR and LAMBDA_FUNCTION_NAME to correspond to your Python module directory (probably in ~/.virtualenvs somewhere) and the AWS Lambda function's name, respectively
Author   ncvc
🌐
Strands Agents
strandsagents.com › latest › documentation › docs › user-guide › deploy › deploy_to_aws_lambda
AWS Lambda new - Strands Agents
This approach gives you full control over where your app code lives and how you want to package it. Assuming that Python & Node dependencies are already installed, package up the assets, run the CDK and deploy: python ./bin/package_for_lambda.py # Bootstrap your AWS environment (if not already ...
🌐
Amazon Web Services
docs.aws.amazon.com › aws lambda › developer guide › building lambda functions with python › define lambda function handler in python
Define Lambda function handler in Python - AWS Lambda
January 31, 2026 - The most common way to declare ... function's deployment package. You can install this library in your development environment by running pip install aws-lambda-typing. The following code ......