Class: EbsPruneSnapshot::Aws

Inherits:
Object
  • Object
show all
Defined in:
lib/ebs_prune_snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Aws

Returns a new instance of Aws.



59
60
61
62
63
# File 'lib/ebs_prune_snapshot.rb', line 59

def initialize(args={})
  args ||= {}
  @access_key = args[:access_key] || ENV['AMAZON_ACCESS_KEY_ID']
  @secret_key = args[:secret_key] || ENV['AMAZON_SECRET_ACCESS_KEY']
end

Instance Attribute Details

#access_keyObject (readonly)

Returns the value of attribute access_key.



57
58
59
# File 'lib/ebs_prune_snapshot.rb', line 57

def access_key
  @access_key
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



57
58
59
# File 'lib/ebs_prune_snapshot.rb', line 57

def secret_key
  @secret_key
end

Instance Method Details

#connectionObject



65
66
67
68
69
# File 'lib/ebs_prune_snapshot.rb', line 65

def connection
  @aws ||= ::AWS::EC2::Base.new(
    :access_key_id => access_key, :secret_access_key => secret_key
  )
end

#delete(snapshot) ⇒ Object



76
77
78
# File 'lib/ebs_prune_snapshot.rb', line 76

def delete(snapshot)
  connection.delete_snapshot(:snapshot_id => snapshot.snapshot_id)
end

#snapshotsObject



71
72
73
74
# File 'lib/ebs_prune_snapshot.rb', line 71

def snapshots
  snapshots = connection.describe_snapshots(:owner => 'self')['snapshotSet']
  snapshots ? snapshots["item"] : []
end