Class: EcsDeploy::AutoScaler::TriggerConfig
- Inherits:
-
Struct
- Object
- Struct
- EcsDeploy::AutoScaler::TriggerConfig
- Includes:
- ConfigBase
- Defined in:
- lib/ecs_deploy/auto_scaler.rb
Instance Attribute Summary collapse
-
#alarm_name ⇒ Object
Returns the value of attribute alarm_name.
-
#region ⇒ Object
Returns the value of attribute region.
-
#state ⇒ Object
Returns the value of attribute state.
-
#step ⇒ Object
Returns the value of attribute step.
Instance Method Summary collapse
Methods included from ConfigBase
Instance Attribute Details
#alarm_name ⇒ Object
Returns the value of attribute alarm_name
269 270 271 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 269 def alarm_name @alarm_name end |
#region ⇒ Object
Returns the value of attribute region
269 270 271 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 269 def region @region end |
#state ⇒ Object
Returns the value of attribute state
269 270 271 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 269 def state @state end |
#step ⇒ Object
Returns the value of attribute step
269 270 271 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 269 def step @step end |
Instance Method Details
#client ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 272 def client Aws::CloudWatch::Client.new( access_key_id: EcsDeploy.config.access_key_id, secret_access_key: EcsDeploy.config.secret_access_key, region: region ) end |
#fetch_alarm ⇒ Object
284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 284 def fetch_alarm res = client.describe_alarms(alarm_names: [alarm_name]) raise "Alarm \"#{alarm_name}\" is not found" if res.metric_alarms.empty? res.metric_alarms[0].tap do |alarm| AutoScaler.logger.debug("#{alarm.alarm_name} state is #{alarm.state_value}") end rescue => e AutoScaler.error_logger.error(e) clear_client end |
#match? ⇒ Boolean
280 281 282 |
# File 'lib/ecs_deploy/auto_scaler.rb', line 280 def match? fetch_alarm.state_value == state end |