Class: OpenStax::Aws::AutoScalingGroup
- Inherits:
-
Object
- Object
- OpenStax::Aws::AutoScalingGroup
- Defined in:
- lib/openstax/aws/auto_scaling_group.rb
Instance Attribute Summary collapse
-
#raw_asg ⇒ Object
readonly
Returns the value of attribute raw_asg.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
Class Method Summary collapse
Instance Method Summary collapse
- #add_tags_not_handled_by_cloudformation(stack_tags) ⇒ Object
- #alarms ⇒ Object
- #desired_capacity ⇒ Object
- #increase_desired_capacity(by:) ⇒ Object
-
#initialize(name:, region:) ⇒ AutoScalingGroup
constructor
A new instance of AutoScalingGroup.
Constructor Details
#initialize(name:, region:) ⇒ AutoScalingGroup
Returns a new instance of AutoScalingGroup.
11 12 13 14 15 16 17 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 11 def initialize(name:, region:) @raw_asg = Aws::AutoScaling::AutoScalingGroup.new( name: name, client: Aws::AutoScaling::Client.new(region: region) ) @region = region end |
Instance Attribute Details
#raw_asg ⇒ Object (readonly)
Returns the value of attribute raw_asg.
3 4 5 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 3 def raw_asg @raw_asg end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
3 4 5 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 3 def region @region end |
Class Method Details
.physical_resource_id_attribute ⇒ Object
7 8 9 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 7 def self.physical_resource_id_attribute :name end |
Instance Method Details
#add_tags_not_handled_by_cloudformation(stack_tags) ⇒ Object
41 42 43 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 41 def () alarms.each { |alarm| alarm. } end |
#alarms ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 33 def alarms client.describe_policies( auto_scaling_group_name: raw_asg.name ).flat_map(&:scaling_policies).flat_map(&:alarms).map do |alarm| OpenStax::Aws::Alarm.new region: region, name: alarm.alarm_name end end |
#desired_capacity ⇒ Object
29 30 31 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 29 def desired_capacity raw_asg.desired_capacity end |
#increase_desired_capacity(by:) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/openstax/aws/auto_scaling_group.rb', line 19 def increase_desired_capacity(by:) # take the smaller of max size or desired+by (or this call raises an exception) increase_to = [raw_asg.max_size, raw_asg.desired_capacity + by].min raw_asg.set_desired_capacity( { desired_capacity: increase_to }) end |