class Awful::Eip
Public Instance Methods
allocate()
click to toggle source
# File lib/awful/eip.rb, line 35 def allocate ec2.allocate_address(domain: options[:domain]).output do |eip| puts eip.public_ip end end
associate(id, instance)
click to toggle source
# File lib/awful/eip.rb, line 55 def associate(id, instance) ec2.associate_address( allocation_id: find_eip(id).allocation_id, instance_id: instance ).association_id.output(&method(:puts)) end
disassociate(id)
click to toggle source
# File lib/awful/eip.rb, line 63 def disassociate(id) ec2.disassociate_address(association_id: find_eip(id).association_id) end
find_eip(thing)
click to toggle source
get an EIP by id or public ip
# File lib/awful/eip.rb, line 12 def find_eip(thing) ec2.describe_addresses.addresses.find do |eip| (thing == eip.public_ip) || (thing == eip.allocation_id) || (thing == eip.association_id) end end
ls()
click to toggle source
# File lib/awful/eip.rb, line 21 def ls ec2.describe_addresses.addresses.output do |eips| if options[:long] print_table eips.map { |i| [i.public_ip, i.allocation_id, i.instance_id, i.private_ip_address, i.domain, i.association_id, i.network_interface_id, i.network_interface_owner_id] }.sort else puts eips.map(&:public_ip).sort end end end
release(id)
click to toggle source
# File lib/awful/eip.rb, line 42 def release(id) find_eip(id).tap do |eip| unless eip.nil? if eip.domain == 'vpc' ec2.release_address(allocation_id: eip.allocation_id) else ec2.release_address(public_ip: eip.public_ip) end end end end