Class: Serverspec::Type::AWS::AutoScaling::Group

Inherits:
Base
  • Object
show all
Defined in:
lib/resources/autoscaling/group.rb

Overview

The Group class exposes the AutoScaling::Group resources

Instance Method Summary collapse

Constructor Details

#initialize(group_name, instance = nil) ⇒ Group

AWS SDK for Ruby v2 Aws::AutoScaling::Client wrapper for initializing a Group resource

Parameters:

  • group_name (String)

    The name of the Group

  • instance (Class) (defaults to: nil)

    Aws::AutoScaling::Client instance

Raises:

  • (RuntimeError)

    if group_name.nil?

  • (RuntimeError)

    if groups.length == 0

  • (RuntimeError)

    if groups.length > 1



15
16
17
18
19
20
# File 'lib/resources/autoscaling/group.rb', line 15

def initialize(group_name, instance = nil)
  check_init_arg 'group_name', 'AutoScaling::Group', group_name
  @group_name = group_name
  @aws = instance.nil? ? Aws::AutoScaling::Client.new : instance
  get_group group_name
end

Instance Method Details

#availability_zonesArray(String)

One or more availability zones for the Group

Returns:

  • (Array(String))


60
61
62
# File 'lib/resources/autoscaling/group.rb', line 60

def availability_zones
  @group.availability_zones
end

#default_cooldownInteger

The number of seconds after a scaling activity completes before any further scaling activities can start

Returns:

  • (Integer)


54
55
56
# File 'lib/resources/autoscaling/group.rb', line 54

def default_cooldown
  @group.default_cooldown
end

#desired_capacityInteger

The size of the Group

Returns:

  • (Integer)


47
48
49
# File 'lib/resources/autoscaling/group.rb', line 47

def desired_capacity
  @group.desired_capacity
end

#enabled_metricsArray(Hash)

The metrics enabled for this Group

Returns:

  • (Array(Hash))


134
135
136
# File 'lib/resources/autoscaling/group.rb', line 134

def enabled_metrics
  @group.enabled_metrics
end

#health_check_grace_periodInteger

The amount of time that AutoScaling waits before checking an instance's health status after being in service

Returns:

  • (Integer)


80
81
82
# File 'lib/resources/autoscaling/group.rb', line 80

def health_check_grace_period
  @group.health_check_grace_period
end

#health_check_typeString

The service of interest for the health status check, which can be either EC2 or ELB

Returns:

  • (String)


73
74
75
# File 'lib/resources/autoscaling/group.rb', line 73

def health_check_type
  @group.health_check_type
end

#instance_countInteger

The number of EC2 Instances associated with the Group

Returns:

  • (Integer)


102
103
104
# File 'lib/resources/autoscaling/group.rb', line 102

def instance_count
  @group.instances.length
end

#instancesArray(Hash)

The EC2 Instances associated with the Group

Examples:

group.instances #=>

[
  {
    instance_id: 'The ID of the instance',
    availability_zone: 'The AZ associated with this instance',
    lifecycle_state: 'A description of current lifecycle state',
    health_status: 'The health status of the instance',
    launch_configuration_name: 'The associated launch config'
  }
]

Returns:

  • (Array(Hash))


96
97
98
# File 'lib/resources/autoscaling/group.rb', line 96

def instances
  @group.instances
end

#launch_configurationString

The name of the associated LaunchConfiguration

Returns:

  • (String)


29
30
31
# File 'lib/resources/autoscaling/group.rb', line 29

def launch_configuration
  @group.launch_configuration_name
end

#load_balancer_namesArray(String)

One or more LoadBalancers associated with the Group

Returns:

  • (Array(String))


66
67
68
# File 'lib/resources/autoscaling/group.rb', line 66

def load_balancer_names
  @group.load_balancer_names
end

#max_sizeInteger

The maximum size of the Group

Returns:

  • (Integer)


41
42
43
# File 'lib/resources/autoscaling/group.rb', line 41

def max_size
  @group.max_size
end

#min_sizeInteger

The minimum size of the Group

Returns:

  • (Integer)


35
36
37
# File 'lib/resources/autoscaling/group.rb', line 35

def min_size
  @group.min_size
end

#placement_groupString

The name of the placement group into which you'll launch your Instances

Returns:

  • (String)


122
123
124
# File 'lib/resources/autoscaling/group.rb', line 122

def placement_group
  @group.placement_group
end

#scaling_policiesArray(Hash)

The policies for the Group

Returns:

  • (Array(Hash))


159
160
161
162
163
# File 'lib/resources/autoscaling/group.rb', line 159

def scaling_policies
  @aws.describe_policies(
    auto_scaling_group_name: @group_name
  ).scaling_policies
end

#statusString

The current state of the Group when a DeleteAutoScalingGroup action is in progress

Returns:

  • (String)


141
142
143
# File 'lib/resources/autoscaling/group.rb', line 141

def status
  @group.status
end

#suspended_processesArray(Hash)

The suspended processes associated with the Group

Examples:

group.suspended_processes #=>

[
  {
    process_name: 'The name of the suspended process',
    suspension_reason: 'The reason that the process was suspended'
  }
]

Returns:

  • (Array(Hash))


115
116
117
# File 'lib/resources/autoscaling/group.rb', line 115

def suspended_processes
  @group.suspended_processes
end

#tagsArray(Hash)

The tags for the Group

Returns:

  • (Array(Hash))


147
148
149
# File 'lib/resources/autoscaling/group.rb', line 147

def tags
  @group.tags
end

#termination_policiesArray(String)

The termination policies for this Group

Returns:

  • (Array(String))


153
154
155
# File 'lib/resources/autoscaling/group.rb', line 153

def termination_policies
  @group.termination_policies
end

#to_sObject

Returns the String representation of AutoScaling::Group



23
24
25
# File 'lib/resources/autoscaling/group.rb', line 23

def to_s
  "AutoScaling Group: #{@group_name}"
end

#vpc_subnetsArray(String)

One or more Subnet IDs, if applicable

Returns:

  • (Array(String))


128
129
130
# File 'lib/resources/autoscaling/group.rb', line 128

def vpc_subnets
  @group.vpc_zone_identifier.split(',').map(&:strip)
end