Skip to content

Instantly share code, notes, and snippets.

@jbarciauskas
Created June 11, 2013 14:00
Show Gist options
  • Save jbarciauskas/5757080 to your computer and use it in GitHub Desktop.
Save jbarciauskas/5757080 to your computer and use it in GitHub Desktop.
require 'fog'
require 'pp'
require 'active_support'
AWS = Fog::Compute.new :provider => 'AWS'
AWS.snapshots.each do |snapshot|
if snapshot.tags['Name'] =~ /pod\d*{3}-\w*-\d*/
if(DateTime.parse(snapshot.created_at.to_iso8601_basic) < (DateTime.now << 1))
print "#{snapshot.tags['Name']} was created more than 1 month ago, deleting..."
AWS.delete_snapshot snapshot.id
print "deleted\n"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment