Class: ElasticBeans::Command::Configure

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_beans/command/configure.rb

Overview

:nodoc: all

Constant Summary collapse

USAGE =
"configure"
DESC =
"Configure the given Elastic Beanstalk application"
LONG_DESC =
<<-LONG_DESC
Configure the given Elastic Beanstalk application.
Specify an environment to configure a single environment within your EB application
Creates and updates configuration templates for each possible environment type.
Updates running environments with the new configuration.

Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
LONG_DESC
VALID_ARGUMENTS =
%w(webserver worker exec scheduler)

Instance Method Summary collapse

Constructor Details

#initialize(internal:, keypair:, public_key:, ssl_certificate_arn:, solution_stack:, option_settings:, option_settings_to_remove:, application:, network:, elastic_beanstalk:, iam:, ui:, environment_type: nil, queue:) ⇒ Configure

Returns a new instance of Configure.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elastic_beans/command/configure.rb', line 20

def initialize(
  internal:,
  keypair:,
  public_key:,
  ssl_certificate_arn:,
  solution_stack:,
  option_settings:,
  option_settings_to_remove:,
  application:,
  network:,
  elastic_beanstalk:,
  iam:,
  ui:,
  environment_type: nil,
  queue:
)
  @internal = internal
  @keypair = keypair
  @public_key = public_key
  @ssl_certificate_arn = ssl_certificate_arn
  @solution_stack = solution_stack
  @option_setting_strings = option_settings
  @option_strings_to_remove = option_settings_to_remove
  @application = application
  @network = network
  @elastic_beanstalk = elastic_beanstalk
  @iam = iam
  @ui = ui
  @environment_type = environment_type
  @queue = queue
  # Required attributes not passed from CLI
  @environments = application.environments
  @threads = []
end

Instance Method Details

#runObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/elastic_beans/command/configure.rb', line 55

def run
  check_environment_status

  Signal.trap("INT") do
    puts "\nInterrupting beans"
    puts "WARNING: Configuration update is partially applied, you should run this command again"
    raise Interrupt
  end
  Signal.trap("TERM") do
    puts "Terminating beans"
    puts "WARNING: Configuration update is partially applied, you should run this command again"
    raise SignalException.new("TERM")
  end

  configure_progressbar
  progressbar.log("Updating configuration templates in #{application.name}...")

  if environment_type
    raise InvalidCommandArgumentError if !VALID_ARGUMENTS.include?(environment_type)
    self.send("configure_#{environment_type}".to_sym)
  else
    # Shared configuration with common values for all environments
    progressbar.log("Updating base configuration template...")
    base_config = ElasticBeans::ConfigurationTemplate::Base.new(
      application: application,
      elastic_beanstalk: elastic_beanstalk,
    )
    base_config.upsert(
      network: network,
      keypair: keypair,
      solution_stack: solution_stack,
      option_settings: option_settings,
      options_to_remove: options_to_remove,
      iam: iam,
    )
    progressbar.increment

    configure_webserver
    configure_exec
    configure_scheduler
    configure_worker
  end

  threads.each(&:join)
  progressbar.finish
end