Last active
August 29, 2015 14:06
-
-
Save anorsich/52ec9eac65c25ce29957 to your computer and use it in GitHub Desktop.
Deploy node.js app to amazon elasticbeanstalk
This file contains 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
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