Last active
August 29, 2015 14:05
-
-
Save mshock/1e2e7e6aba97a985a5b7 to your computer and use it in GitHub Desktop.
Delete all non-running application versions from a specific application in AWS Elastic Beanstalk. (Despite the doc's claim, currently running app versions CAN be deleted so a check is necessary)
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
#! perl -w | |
use strict; | |
use feature 'say'; | |
my $application = $ARGV[0] || 'massdrop-production'; | |
my @app_versions_lines = split /\n/, `/usr/local/bin/aws elasticbeanstalk describe-application-versions --application-name $application`; | |
my @environment_lines = split /\n/, `/usr/local/bin/aws elasticbeanstalk describe-environments`; | |
my %running; | |
for (@environment_lines) { | |
$running{$1} =1 if /\t(git-\S+)$/; | |
} | |
for (@app_versions_lines) { | |
if (/APPLICATIONVERSIONS\t(\S+)\t.+\t.+\t(\S+)$/ && $1 eq $application && !exists $running{$2}) { | |
say "deleting $1 - $2"; | |
say `/usr/local/bin/aws elasticbeanstalk delete-application-version --application-name $application --version-label $2`; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment