Class: EcsRailsConsole::Cli

Inherits:
Core
  • Object
show all
Defined in:
lib/ecs_rails_console/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Cli

Returns a new instance of Cli.



15
16
17
18
19
# File 'lib/ecs_rails_console/cli.rb', line 15

def initialize(options)
  super()
  @environment = options[:environment]
  @command = options[:command]
end

Class Method Details

.run!(options) ⇒ Object



11
12
13
# File 'lib/ecs_rails_console/cli.rb', line 11

def self.run!(options)
  new(options).run!
end

Instance Method Details

#run!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ecs_rails_console/cli.rb', line 21

def run!
  puts "Cluster name: #{cluster_name}"

  task_description = run_task

  public_ip = get_public_ip(task_description)

  puts "it is running on: #{public_ip}"

  system("ssh #{SSH_OPTIONS} #{ssh_user}@#{public_ip} 'cd /app ; #{command}'")
rescue Aws::ECS::Errors::ExpiredTokenException
  puts "\nHey, it seems your token expired. Authenticate on AWS give another try."
end