Class: CloudFormationTool::CLI::Servers
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- CloudFormationTool::CLI::Servers
- Includes:
- CloudFormationTool
- Defined in:
- lib/cloud_formation_tool/cli/servers.rb
Constant Summary
Constants included from CloudFormationTool
Instance Method Summary collapse
Methods included from CloudFormationTool
#aws_config, #awsas, #awscdn, #awscf, #awscreds, #awsec2, #awsecs, #awss3, #cf_bucket_name, #find_profile, #profile, #region, #s3_bucket_name
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cloud_formation_tool/cli/servers.rb', line 13 def execute st = CloudFormation::Stack.new(stack_name) ts = st.asgroups.select do |res| asg_name.nil? or (res.logical_resource_id == asg_name) end.collect do |res| Thread.new do asg = awsas.describe_auto_scaling_groups({ auto_scaling_group_names: [ res.physical_resource_id ] }).auto_scaling_groups.first if asg.nil? [] else asg.instances.collect do |i| Aws::EC2::Instance.new i.instance_id, client: awsec2 end.collect do |i| ips = [ i.public_ip_address ] + i.network_interfaces.collect(&:ipv_6_addresses).flatten.collect(&:ipv_6_address) "#{res.logical_resource_id.ljust(30, ' ')} '#{i.public_dns_name}' (#{ips.join(', ')})" end end end end ts.each(&:join) puts ts.select{ |t| t.value.length > 0 }.collect { |t| t.value.join "\n" } end |