Module: Furikake::Resources::Ec2
- Defined in:
- lib/furikake/resources/ec2.rb
Class Method Summary collapse
Class Method Details
.get_resources ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/furikake/resources/ec2.rb', line 21 def get_resources ec2 = Aws::EC2::Client.new params = {} instances = [] loop do res = ec2.describe_instances(params) res.reservations.each do |r| r.instances.each do |i| instance = [] instance << 'N/A' if i..map(&:to_h).all? { |h| h[:key] != 'Name' } i..each do |tag| instance << tag.value if tag.key == 'Name' end instance << i.instance_id instance << i.instance_type instance << i.placement.availability_zone instance << i.private_ip_address if i.public_ip_address.nil? instance << ' ' else instance << i.public_ip_address end instance << i.state.name instances << instance end end break if res.next_token.nil? params[:next_token] = res.next_token end instances end |
.report(format = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/furikake/resources/ec2.rb', line 4 def report(format = nil) instance = get_resources contents = { title: 'EC2', resources: [ { subtitle: '', header: ['Name', 'Instance ID', 'Instance Type', 'Availability Zone', 'Private IP Address', 'Public IP Address', 'State'], resource: instance } ] } Furikake::Formatter.shaping(format, contents) end |