Created
October 20, 2015 13:31
-
-
Save drei01/7b905415c1a8c39c52cf to your computer and use it in GitHub Desktop.
AWS CLI - Deploy Beanstalk Application Version
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
#!/bin/bash | |
appname=$1 | |
envname=$2 | |
versionid=$3 | |
#if version id is not set, get the latest | |
if [ -z "$versionlabel" ]; then | |
#get the latest application version, piping to sed to remove quotes from string | |
versionid="$(aws elasticbeanstalk describe-application-versions --application-name $appname | jq '.ApplicationVersions[0].VersionLabel' | sed -e 's/^"//' -e 's/"$//')" | |
fi | |
#exist if version id is null, i.e jq couldn't parse a valid version | |
if [ "$versionid" == "null" ]; then | |
echo "Failed to locate latest application version" >&2 | |
exit 5 | |
fi | |
#deploy the application version | |
echo "Deploying application version $versionid to environment $envname" | |
aws elasticbeanstalk update-environment --environment-name $envname --version-label $versionid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment