Module: Tapjoy::TassLib::AWS::Autoscaling::Group

Defined in:
lib/tapjoy/tass-lib/Autoscaling/group.rb

Overview

This module includes autoscaling group calls to AWS

Class Method Summary collapse

Class Method Details

.clientObject



8
9
10
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 8

def client
  @client ||= Tapjoy::TassLib::AWS::Autoscaling.client
end

.create(zones:, health_check_type: nil, tags:, vpc_subnets: nil, create_elb:, **unused_values) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 33

def create(zones:, health_check_type: nil, tags:,
  vpc_subnets: nil, create_elb:, **unused_values)

  group_hash = {
    auto_scaling_group_name: Tapjoy::TassLib.scaler_name,
    availability_zones: zones,
    launch_configuration_name: Tapjoy::TassLib.config_name,
    min_size: 0, max_size: 0, desired_capacity: 0,
    termination_policies: ['OldestInstance'],
    vpc_zone_identifier: vpc_subnets,
    tags: Tapjoy::TassLib::Autoscaling::Group.new.generate_tags(tags)
  }

  if create_elb
    group_hash.merge!({
      load_balancer_names: [Tapjoy::TassLib.elb_name],
      health_check_type: health_check_type,
      health_check_grace_period: 300,
      })
  end

  self.client.create_auto_scaling_group(**group_hash)
end

.delete(force_delete: true) ⇒ Object



19
20
21
22
23
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 19

def delete(force_delete: true)
  self.client.delete_auto_scaling_group(
  auto_scaling_group_name: Tapjoy::TassLib.scaler_name,
  force_delete: force_delete)
end

.describeObject



25
26
27
28
29
30
31
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 25

def describe
  self.client.describe_auto_scaling_groups(
    auto_scaling_group_names: [
      Tapjoy::TassLib.scaler_name
    ]
  )[0][0]
end

.resize(min_size: 0, max_size: 0, desired_capacity: 0) ⇒ Object



12
13
14
15
16
17
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 12

def resize(min_size: 0, max_size: 0, desired_capacity:0)
  self.client.update_auto_scaling_group(
    auto_scaling_group_name: Tapjoy::TassLib.scaler_name,
    min_size: min_size, max_size: max_size,
    desired_capacity: desired_capacity)
end

.update(**asg_options_hash) ⇒ Object



57
58
59
60
61
# File 'lib/tapjoy/tass-lib/Autoscaling/group.rb', line 57

def update(**asg_options_hash)
  update_hash = {auto_scaling_group_name: Tapjoy::TassLib.scaler_name}
  update_hash.merge!(asg_options_hash)
  self.client.update_auto_scaling_group(**update_hash)
end