Skip to content

aws build deployment package

KimJeongChul edited this page Apr 24, 2019 · 1 revision

Build AWS Lambda deployment package

  1. Started t2.micro EC2 instance
  2. Tried the commands
sudo yum -y update
sudo yum -y upgrade
sudo yum -y groupinstall "Development Tools"
sudo yum -y install blas --enablerepo=epel
sudo yum -y install lapack --enablerepo=epel
sudo yum -y install Cython --enablerepo=epel
sudo yum install python27-devel python27-pip gcc
  1. Created the virtual environment:
virtualenv ~/env
source ~/env/bin/activate
  1. Installed the packages:
pip install [LIBRARY]
  1. Remove unnecessary file
cd ~/env/lib64/python2.7/dist-packages
rm -rf setuptools* wheel* pip* pkg*
find . -type d -name "tests" -exec rm -rf {} +
find -name "*.so" | xargs strip
find -name "*.so.*" | xargs strip
find . -name \*.pyc -delete
  1. Zip example
cd ~/env/lib64/python2.7/dist-packages
zip -r9 ~/[LIBRARY].zip
zip -g [LIBRARY].zip lambda_function.py
  1. Update your code
aws lambda update-function-code --function-name [FUNCTION-ARN] --zip-file fileb://[LIBRARY].zip