Last active
February 13, 2017 23:19
-
-
Save harai/a639f3d1784914eac8ba to your computer and use it in GitHub Desktop.
Setting Up Build Environment of AWS Lambda
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e -x | |
yum -y update | |
yum -y upgrade | |
yum -y groupinstall "Development Tools" | |
yum -y install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel git | |
export HOME=/home/ec2-user | |
export PYENV_ROOT=/var/task/pyenv | |
LAMBDA=/var/task | |
mkdir -p $LAMBDA | |
cd $LAMBDA | |
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash | |
cat << 'EOT' >> $HOME/.bash_profile | |
export PATH="/var/task/pyenv/bin:$PATH" | |
eval "$(pyenv init -)" | |
eval "$(pyenv virtualenv-init -)" | |
EOT | |
. $HOME/.bash_profile | |
hash -r | |
pyenv install 3.5.1 | |
cd pyenv | |
shopt -s extglob | |
rm -fr !(versions) .git | |
find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | sudo xargs rm -rf | |
cd versions/3.5.1/bin/ | |
rm python3.5m | |
ln -s python3.5 python3.5m | |
cd $LAMBDA | |
pyenv/versions/3.5.1/bin/pip install --upgrade pip | |
pyenv/versions/3.5.1/bin/pip install virtualenv | |
pyenv/versions/3.5.1/bin/virtualenv .venv | |
pyenv/versions/3.5.1/bin/virtualenv --relocatable .venv | |
chown -R ec2-user:ec2-user $LAMBDA | |
zip --symlinks -r ~/app.zip . | |
aws s3 cp ~/app.zip s3://$BUCKET/lambda-deploy/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment