Skip to content

Using Docker to build and deploy Python lambda from MacOS

Notifications You must be signed in to change notification settings

zijing07/aws-lambda-python-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Amplify PyLambda Deploy Demo

This packge showcases how to deploy a Amplify-created PyLambda from your MacOS.

Manual

If you are interested to know more, please check out this article.

Issue

If we directly build and deploy a python lambda from MacOS, we will see errors like:

{
  "errorMessage": "Unable to import module 'index': No module named 'regex._regex'",
  "errorType": "Runtime.ImportModuleError",
  "stackTrace": []
}

This is because pipenv is downloading the MacOS binaries, which are not compatible with AWS Lambda runtime: Linux.

Fix

By using Docker, we could conveniently create a Linux build and deploy environment. Then developers can quickly deploy and test their code before pushing them to CI/CD.

How To Use

Please go to the PyLambda folder, and checkout the following two files:

  • Dockerfile
  • dockerCmd.sh

Then run the following command at the PyLambda folder:

docker build -t tmp-awslambda . && docker run --rm tmp-awslambda

About

Using Docker to build and deploy Python lambda from MacOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages