Skip to content

Instantly share code, notes, and snippets.

@drei01
Created October 20, 2015 13:31
Show Gist options
  • Save drei01/7b905415c1a8c39c52cf to your computer and use it in GitHub Desktop.
Save drei01/7b905415c1a8c39c52cf to your computer and use it in GitHub Desktop.
AWS CLI - Deploy Beanstalk Application Version
#!/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