Skip to content

Instantly share code, notes, and snippets.

@nabilfreeman
Created August 22, 2016 09:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabilfreeman/680d73bd9e5642881babeb18662328ba to your computer and use it in GitHub Desktop.
Save nabilfreeman/680d73bd9e5642881babeb18662328ba to your computer and use it in GitHub Desktop.
AWS Lambda deploy script for Node.js
# AWS Lambda Node.js deploy script
# @author Nabil Freeman <nabil@instafork.com> (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