Class: AwsEc2DnsName
- Inherits:
-
Object
- Object
- AwsEc2DnsName
- Defined in:
- lib/aws_ec2_dns_name.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
-
#initialize(region: nil, access_key_id: nil, secret_access_key: nil) ⇒ AwsEc2DnsName
constructor
A new instance of AwsEc2DnsName.
- #list ⇒ Array<Hash>
Constructor Details
#initialize(region: nil, access_key_id: nil, secret_access_key: nil) ⇒ AwsEc2DnsName
Returns a new instance of AwsEc2DnsName.
10 11 12 13 14 |
# File 'lib/aws_ec2_dns_name.rb', line 10 def initialize(region: nil, access_key_id: nil, secret_access_key: nil) self.client = Aws::EC2::Client.new(region: region, access_key_id: access_key_id, secret_access_key: secret_access_key) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/aws_ec2_dns_name.rb', line 5 def client @client end |
Instance Method Details
#list ⇒ Array<Hash>
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/aws_ec2_dns_name.rb', line 17 def list client.describe_instances.first.reservations.map do |reservation| instance = reservation.instances.first name_tag = instance..find { |tag| tag.key == "Name" }.value dns_name = dns_name(instance) next if dns_name.nil? { name_tag: name_tag, dns_name: dns_name, } end.sort_by { |h| h[:name_tag] } end |