Skip to content

Instantly share code, notes, and snippets.

@baldowl
Created February 8, 2012 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baldowl/1772132 to your computer and use it in GitHub Desktop.
Save baldowl/1772132 to your computer and use it in GitHub Desktop.
Deleting EBS Snapshots with aws-sdk
require 'rubygems'
require 'active_support/time'
require 'aws-sdk'
threshold = 2.months.ago
ec2 = AWS::EC2.new
ec2.shapshots.with_owner(:self).
select {|s| s.volume_id == 'vol-12345678' && s.start_time < threshold}.
each {|s| puts "Bye-bye #{s.description}"; s.delete}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment