class AwsCftTools::Runbooks::Hosts

Hosts - report on EC2 instances

@example

% aws-cli hosts                  # list all known EC2 instances
% aws-cli hosts -e QA            # list all known EC2 instances in the QA environment
% aws-cli hosts -r Bastion -e QA # list all known Bastion hosts in the QA environment

Public Instance Methods

columns() click to toggle source

@return [Array<String>]

# File lib/aws_cft_tools/runbooks/hosts.rb, line 24
def columns
  %w[public_ip private_ip] + environment_column + role_column + ['instance']
end
items() click to toggle source

@return [Array<OpenStruct>]

# File lib/aws_cft_tools/runbooks/hosts.rb, line 17
def items
  client.instances.sort_by(&method(:sort_key))
end

Private Instance Methods

environment_column() click to toggle source
# File lib/aws_cft_tools/runbooks/hosts.rb, line 34
def environment_column
  options[:environment] ? [] : ['environment']
end
role_column() click to toggle source
# File lib/aws_cft_tools/runbooks/hosts.rb, line 38
def role_column
  options[:role] ? [] : ['role']
end
sort_key(host) click to toggle source
# File lib/aws_cft_tools/runbooks/hosts.rb, line 30
def sort_key(host)
  [host.environment, host.role, host.ip].compact
end