Module: AwsOpsworksDataHelper
- Defined in:
- lib/easy_aws_ssh/aws_opsworks_data_helper.rb
Instance Method Summary collapse
- #all_stack_instance_names ⇒ Object
- #all_stack_names ⇒ Object
- #instance_data ⇒ Object
- #instance_ip ⇒ Object
- #ssh_key_name ⇒ Object
- #stack_data ⇒ Object
- #stack_id ⇒ Object
- #stack_instance_data ⇒ Object
Instance Method Details
#all_stack_instance_names ⇒ Object
19 20 21 |
# 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 ⇒ Object
23 24 25 |
# 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 ⇒ Object
7 8 9 |
# 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 ⇒ Object
11 12 13 |
# File 'lib/easy_aws_ssh/aws_opsworks_data_helper.rb', line 11 def instance_ip instance_data['PublicIp'] end |
#ssh_key_name ⇒ Object
15 16 17 |
# File 'lib/easy_aws_ssh/aws_opsworks_data_helper.rb', line 15 def ssh_key_name instance_data['SshKeyName'] end |
#stack_data ⇒ Object
27 28 29 |
# 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 ⇒ Object
31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
3 4 5 |
# 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 |