Created
March 16, 2016 05:33
-
-
Save KensoDev/646de085dc8fd4c4b39d to your computer and use it in GitHub Desktop.
Delete old ElasticBeanstalk application versios
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
echo "Starting to delete versions of $APP" | |
while read ver; do | |
echo "Deleting version $ver" | |
aws elasticbeanstalk delete-application-version --version-label $ver --profile $PROFILE --application-name $APP | |
echo "Version $ver deleted!" | |
done |
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
./list-versions.sh | ./parse_versions.rb | ./delete-versions.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
aws elasticbeanstalk describe-application-versions --profile $PROFILE |
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
#!/usr/bin/env ruby | |
require 'time' | |
require 'json' | |
ALLOWED_NAMES = [ENV['APP']] | |
t = DateTime.now - 14 | |
json = ARGF.read | |
hash = JSON.parse(json) | |
versions = hash["ApplicationVersions"] | |
versions.each do |ver| | |
application_name = ver["ApplicationName"] | |
created_at = DateTime.parse(ver["DateCreated"]) | |
if ALLOWED_NAMES.include?(application_name) | |
if t > created_at | |
puts "#{ver["VersionLabel"]}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment