Class: EcsDeploy::AutoScaler::AutoScalingConfig

Inherits:
Struct
  • Object
show all
Extended by:
ConfigBase::ClassMethods
Includes:
ConfigBase
Defined in:
lib/ecs_deploy/auto_scaler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigBase::ClassMethods

client_table

Methods included from ConfigBase

#initialize

Instance Attribute Details

#buffer ⇒ Object

Returns the value of attribute buffer



249
250
251
# File 'lib/ecs_deploy/auto_scaler.rb', line 249

def buffer
  @buffer
end

#name ⇒ Object

Returns the value of attribute name



249
250
251
# File 'lib/ecs_deploy/auto_scaler.rb', line 249

def name
  @name
end

#region ⇒ Object

Returns the value of attribute region



249
250
251
# File 'lib/ecs_deploy/auto_scaler.rb', line 249

def region
  @region
end

Instance Method Details

#client ⇒ Object



253
254
255
256
257
258
259
# File 'lib/ecs_deploy/auto_scaler.rb', line 253

def client
  self.class.client_table[region] ||= Aws::AutoScaling::Client.new(
    access_key_id: EcsDeploy.config.access_key_id,
    secret_access_key: EcsDeploy.config.secret_access_key,
    region: region
  )
end

#update_auto_scaling_group(total_service_count) ⇒ Object



261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/ecs_deploy/auto_scaler.rb', line 261

def update_auto_scaling_group(total_service_count)
  desired_capacity = total_service_count + buffer.to_i
  client.update_auto_scaling_group(
    auto_scaling_group_name: name,
    min_size: desired_capacity,
    max_size: desired_capacity,
    desired_capacity: desired_capacity,
  )
  AutoScaler.logger.info "Update auto scaling group \"#{name}\": desired_capacity -> #{desired_capacity}"
rescue => e
  AutoScaler.error_logger.error(e)
  self.class.client_table[region] = nil
end