module AwsOpsworksDataHelper

Public Instance Methods

all_stack_instance_names() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 19
def all_stack_instance_names
  stack_instance_data.map{|data| data['Hostname']}
end
all_stack_names() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 23
def all_stack_names
  stack_data.map{|s| s['Name']}.sort
end
instance_data() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 7
def instance_data
  stack_instance_data.find{|data| data['Hostname'] == @instance_name}
end
instance_ip() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 11
def instance_ip
  instance_data['PublicIp']
end
ssh_key_name() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 15
def ssh_key_name
  instance_data['SshKeyName']
end
stack_data() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 27
def stack_data
  @stack_data = JSON.parse(`aws opsworks describe-stacks`)['Stacks']
end
stack_id() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 31
def stack_id
  stack = stack_data.select{|s| s['Name'].downcase == @stack_name.downcase}.first
  if stack
    stack['StackId']
  else
    raise "Stack not found.  Available opsworks stacks: #{all_stack_names}"
  end
end
stack_instance_data() click to toggle source
# File lib/easy_aws_ssh/aws_opsworks_data_helper.rb, line 3
def stack_instance_data
  @stack_instance_data ||= JSON.parse(`aws opsworks describe-instances --stack-id=#{stack_id}`)['Instances']
end