module Aws::OpsworksCssh
Constants
- VERSION
Public Class Methods
start_opsworks_cssh(stack_name,user,force_private)
click to toggle source
# File lib/aws/opsworks_cssh.rb, line 9 def self.start_opsworks_cssh(stack_name,user,force_private) @resp_instances options = {} options['user'] = user opsworks = Aws::OpsWorks::Client.new(region: 'us-east-1') # sample stack_id = 'c06853f8-428e-44f7-8f6e-326703bf501e' #sample stack name = 'Redcoon' resp_stacks = opsworks.describe_stacks #resp = opsworks.describe_instances({:stack_id => stack_id}) resp_stacks.stacks.each do |stack| if stack.name == stack_name @resp_instances = opsworks.describe_instances({:stack_id => stack.stack_id}) break end end unless @resp_instances $stderr.puts "No such stack: #{stack_name}" exit 1 end dns = @resp_instances.instances.map { |instance| if force_private == "private" instance.private_ip || instance.public_ip else instance.public_ip || instance.private_ip end } cssh = (/darwin/ =~ RUBY_PLATFORM) ? 'csshX' : 'cssh' cmd = "#{cssh} -l #{options['user']} #{dns.join ' '}" puts "Connecting to #{dns.length} instances" puts cmd exec cmd end