Created
December 17, 2015 21:00
-
-
Save sap1ens/a426fe1067f49192b94f to your computer and use it in GitHub Desktop.
eb-versions-cleanup.sh
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
#!/bin/bash | |
_appName=$1 | |
_limit=$2 | |
echo "$(date) checking app:$_appName with limit:$_limit " | |
# get app versions above the limit as a list | |
versions=$(aws elasticbeanstalk describe-application-versions\ | |
--application-name $_appName\ | |
--query "ApplicationVersions[*].[VersionLabel]"\ | |
--output text | tail -n +$_limit) | |
# delete obsolete versions | |
for version in $versions | |
do | |
aws elasticbeanstalk delete-application-version --delete-source-bundle\ | |
--version-label "$version" --application-name "$_appName" | |
echo "$(date) $_appName:$version deleted" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment