Skip to content

Instantly share code, notes, and snippets.

@eccyan
Created January 7, 2016 05:30
Show Gist options
  • Save eccyan/0216d44cab132b575003 to your computer and use it in GitHub Desktop.
Save eccyan/0216d44cab132b575003 to your computer and use it in GitHub Desktop.
Rotate application versions in Elastic Beanstalk
#!/bin/bash
APPNAME=
ROTATE_COUNT=200
application_versions() {
aws elasticbeanstalk describe-application-versions --application-name $APPNAME | \
jq -r '.ApplicationVersions | .[] | .VersionLabel' ;
}
delete_application_versions() {
for label in $1 ; do
echo Delete application version: $label ;
aws elasticbeanstalk delete-application-version --application-name $APPNAME --version-label $label ;
done
}
delete_application_versions "$(application_versions | tail -n +$(expr $ROTATE_COUNT + 1))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment