Class: EasyEb::Ssh

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_eb/ssh.rb

Class Method Summary collapse

Class Method Details

.start!(environment: nil, command: nil, ssh: nil, eb_flags: nil, env_command: "bin/ebenv", region: nil) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/easy_eb/ssh.rb', line 3

def self.start!(environment: nil, command: nil, ssh: nil, eb_flags: nil, env_command: "bin/ebenv", region: nil)
  bash_args = command && "-c \\\"#{env_command} #{command}\\\""
  tty_flag = command && "-t"
  ssh_flag = ssh && "-e #{ssh}"
  command_arg = [
    tty_flag,
    "cd /var/app/current; sudo bash -i #{bash_args}"
  ].compact.join(" ")

  args = [
    region && "--region #{region}",
    eb_flags,
    environment,
    ssh_flag,
    "--command \"#{command_arg}\""
  ].compact.join(" ")

  system("eb ssh #{args}", exception: true)
end