Skip to content

Instantly share code, notes, and snippets.

@anorsich
Last active August 29, 2015 14:06
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 anorsich/52ec9eac65c25ce29957 to your computer and use it in GitHub Desktop.
Save anorsich/52ec9eac65c25ce29957 to your computer and use it in GitHub Desktop.
Deploy node.js app to amazon elasticbeanstalk
APP_NAME="sample"
ENV_NAME="sample-production"
#%build.vcs.number% is sha of commit taken from TeamCity
APP_VERSION=$(date -u +"%%FT%%T-UTC")-${ENV_NAME}-`%build.vcs.number%`
echo APP_VERSION is ${APP_VERSION}
#remove previous build if exists
rm -f appName.zip
#grunt task which is create deployment package and zip it
grunt deploy-aws --speakup-version=${APP_VERSION}
# delete any version with the same name (based on the short revision)
aws elasticbeanstalk delete-application-version --application-name "${APP_NAME}" --version-label "${APP_VERSION}" --delete-source-bundle
#copy zip archive to S3
echo Started uploading to S3
aws s3 cp ./appName.zip s3://%S3_BUCKET%/${APP_VERSION}-${APP_NAME}.zip
# create a new version and update the environment to use this version
aws elasticbeanstalk create-application-version --application-name "${APP_NAME}" --version-label "${APP_VERSION}" --source-bundle S3Bucket="%S3_BUCKET%",S3Key="${APP_VERSION}-${APP_NAME}.zip"
aws elasticbeanstalk update-environment --environment-name "${ENV_NAME}" --version-label "${APP_VERSION}"
# wait while changes are propagated to the amazon
# see wait.sh gist
./scripts.dev/wait.sh "${APP_VERSION}"
echo Finished deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment