Class: Tapjoy::AutoscalingBootstrap::LaunchConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/tapjoy/autoscaling_bootstrap/launch_configuration.rb

Overview

This class is the central launching point for autoscaling group update

Instance Method Summary collapse

Constructor Details

#initialize(new_config, aws_env, user_data) ⇒ LaunchConfiguration

Initialize the class



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/tapjoy/autoscaling_bootstrap/launch_configuration.rb', line 6

def initialize(new_config, aws_env, user_data)
  Tapjoy::AutoscalingBootstrap.scaler_name = "#{new_config[:name]}-group"
  Tapjoy::AutoscalingBootstrap.config_name = "#{new_config[:name]}-config"

  updated_config = current.to_hash.merge!(new_config)

  lc_name = "#{Tapjoy::AutoscalingBootstrap.config_name}_#{date_stamp}"
  update(
    config_name: lc_name,
    scaler_name: Tapjoy::AutoscalingBootstrap.scaler_name,
    user_data: user_data,
    updated_config: updated_config, aws_env: aws_env
  )
end

Instance Method Details

#currentObject



21
22
23
24
25
26
27
28
29
# File 'lib/tapjoy/autoscaling_bootstrap/launch_configuration.rb', line 21

def current
  begin
    current_config_name = Tapjoy::AutoscalingBootstrap::AWS::Autoscaling::Group.describe[:launch_configuration_name]
  rescue NoMethodError
    raise Tapjoy::AutoscalingBootstrap::Errors::InvalidAutoscalingGroup
  end
  puts "Current launch config is: #{current_config_name}\n\n"
  Tapjoy::AutoscalingBootstrap::AWS::Autoscaling::LaunchConfig.describe(current_config_name)
end

#date_stampObject



38
39
40
# File 'lib/tapjoy/autoscaling_bootstrap/launch_configuration.rb', line 38

def date_stamp
  Time.now.utc.strftime('%Y%m%d-%H%M%S')
end

#update(config_name:, scaler_name: 'NaS', user_data: user_data, updated_config:, aws_env:) ⇒ Object



31
32
33
34
35
36
# File 'lib/tapjoy/autoscaling_bootstrap/launch_configuration.rb', line 31

def update(config_name:, scaler_name: 'NaS', user_data: user_data,
  updated_config:, aws_env:)
  Tapjoy::AutoscalingBootstrap.config_name = config_name
  Tapjoy::AutoscalingBootstrap.config.create(updated_config, aws_env,
    user_data)
end