Skip to content

Instantly share code, notes, and snippets.

@harai harai/script.sh
Last active Feb 13, 2017

Embed
What would you like to do?
Setting Up Build Environment of AWS Lambda
#!/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
You can’t perform that action at this time.