I am trying to get up and running with AWS Lambda Python (beginner in Python btw) but having some problems with including MySQL dependency. I am trying to follow the instruc
Using lambda-docker you can set up and test your Lambda functions without access to a like-wise Linux environment.
To set up your lambda, use a lambda-docker build image to run a detached docker container and run pip install <package>
commands on the container. Then export the container, grab the installed packages under usr/lib
, and place them in your AWS Lambda package.
Then you can test for compatibility by running your lambda on a lambda-docker image. If it works, go forth and upload to AWS Lambda with confidence.
docker run -d -v "$PWD":/var/task lambci/lambda:build-python2.7 tail -f /dev/null
docker ps
docker exec 0c55aae443e6 pip install pandas
docker exec 0c55aae443e6 pip install sqlalchemy
docker exec 0c55aae443e6 pip freeze
docker exec 0c55aae443e6 python -c "import site; print(site.getsitepackages())"
docker container export -o lambda_ready_container 0c55aae443e6
Lambda -> Layers (add new layer)
download zip of pymysql from https://pypi.org/project/PyMySQL/#files
when you download, unzip then rename parent folder to "python" then rezip (should be python/{where the pysqlfiles are}
add a layer to Lambda called 'pymysql' and upload that zip
then in Lambda function import pymysql
I believe your issue is mostly down to missing development packages. I think you will need the following:
sudo yum -y install mysql-devel