Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private IP hostname supported #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions lib/elbas/aws/instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ module AWS
class Instance < Base
STATE_RUNNING = 16.freeze

attr_reader :aws_counterpart, :id, :state
attr_reader :aws_counterpart, :id, :state, :hostname

def initialize(id, public_dns, state)
def initialize(id, hostname, state)
@id = id
@public_dns = public_dns
@hostname = hostname
@state = state
@aws_counterpart = aws_namespace::Instance.new id, client: aws_client
end

def hostname
@public_dns
end

def running?
state == STATE_RUNNING
end
Expand Down
3 changes: 2 additions & 1 deletion lib/elbas/aws/instance_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class InstanceCollection < Base
def initialize(ids)
@ids = ids
@instances = query_instances_by_ids(ids).map do |i|
Instance.new(i.instance_id, i.public_dns_name, i.state.code)
hostname = i.public_dns_name != "" ? i.public_dns_name : i.private_ip_address
Instance.new(i.instance_id, hostname, i.state.code)
end
end

Expand Down