Skip to content

Instantly share code, notes, and snippets.

@KensoDev
Created March 16, 2016 05:33
Show Gist options
  • Save KensoDev/646de085dc8fd4c4b39d to your computer and use it in GitHub Desktop.
Save KensoDev/646de085dc8fd4c4b39d to your computer and use it in GitHub Desktop.
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