Delete old ElasticBeanstalk application versios
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 |
./list-versions.sh | ./parse_versions.rb | ./delete-versions.sh |
aws elasticbeanstalk describe-application-versions --profile $PROFILE |
#!/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