Sha256: 859eacf4c561476fbc2ffb2fb6ec50bd7b48da59884c98b4201e3084fcd149e8

Contents?: true

Size: 533 Bytes

Versions: 2

Compression:

Stored size: 533 Bytes

Contents

require 'pp'

class AwsClean::Keypair < AwsClean::Base
  def clean
    return if ENV['TEST'] # hack for specs

    inventory = AwsInventory::Keypair.new(header: false)
    inventory.data.each do |row|
      key_name, instances_count = row
      in_use = instances_count > 0
      next if in_use

      sure = are_you_sure?("About to keypair #{key_name}")
      if sure
        ec2.delete_key_pair(key_name: key_name)
        puts "Deleted #{key_name}"
      else
        puts "Did not delete #{key_name}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws-clean-0.2.0 lib/aws_clean/keypair.rb
aws-clean-0.1.0 lib/aws_clean/keypair.rb