Skip to content

Instantly share code, notes, and snippets.

@nwhobart
Last active October 27, 2015 20:05
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 nwhobart/c73ea8fde56cd564360e to your computer and use it in GitHub Desktop.
Save nwhobart/c73ea8fde56cd564360e to your computer and use it in GitHub Desktop.
How we deploy to AWS Elastic Beanstalk with multiple sumo logic accounts.
#!/bin/bash
# simple script for using eb deploy in a bash script
app=$(cat config/application.rb |grep -i "module" |awk '{ print tolower ($2) }' )
current_date=$(date +"%Y%m%d-%T%Z")
current_user=$(whoami)
if [ ! -f .elasticbeanstalk/config.yml ]; then
echo "You need to run 'eb init' first!"
else
echo "*** Please note that labels are automatically generated for you ***"
sleep 1
read -p "Which environment are you deploying? (qa, staging) " enviro
read -p "Which branch would you like to deploy? " branch
#the following line has been removed to avoid folks reploying with identical lables
#read -p "Please name/label this deployment: " label
git checkout $branch
git pull
## to account for multiple sumo logic accounts we must change the ebextension file so that sumo logic sends non prod logging data to the non prod account. ACCOUNT!
if [[ $enviro == qa ]] || [[ $enviro == staging ]]; then
sed -i '' 's/'$app'.config/'$app'-'$enviro'.config/g' .ebextensions/0006_sumologic.config
git add .ebextensions/0006_sumologic.config && git commit -m " for deploy only - will be (soft) reset "
fi
eb deploy $app-$enviro --label $current_date-$current_user --timeout 30 -v
# we need to reset the repository back to the state it was in before the commit. we don't want to push this change to origin
if [[ $enviro == qa ]] || [[ $enviro == staging ]]; then
git reset --soft HEAD~1
git reset HEAD .ebextensions/0006_sumologic.config
git checkout .ebextensions/0006_sumologic.config
fi
echo "Congratulations, you've deployed $branch to $enviro"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment