This packge showcases how to deploy a Amplify-created PyLambda from your MacOS.
If you are interested to know more, please check out this article.
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.
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.
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