Created
August 22, 2016 09:24
-
-
Save nabilfreeman/680d73bd9e5642881babeb18662328ba to your computer and use it in GitHub Desktop.
AWS Lambda deploy script for Node.js
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
# AWS Lambda Node.js deploy script | |
# @author Nabil Freeman <[email protected]> (https://github.com/nabilfreeman) | |
# *************************************** | |
# Environment variables required: | |
# AWS_ACCESS_KEY_ID=XXXXXXX | |
# AWS_SECRET_ACCESS_KEY=XXXXXXXX | |
# AWS_DEFAULT_REGION=eu-west-1 | |
# LAMBDA_FUNCTION_NAME=asdfghjkl | |
# *************************************** | |
# delete node_modules folder and re-install all modules | |
rm -rf node_modules | |
npm install | |
# delete .env and overwrite | |
rm -f .env | |
cp .env.development .env | |
# create zip file, ignore .git directory | |
zip -r exports.zip . -x "*.git*" | |
# install AWS CLI (if not exists) and then upload to AWS lambda | |
pip install awscli | |
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --zip-file fileb://exports.zip | |
# clean up | |
rm -f exports.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment