Class: Serverspec::Type::AWS::CloudWatch::Alarm

Inherits:
Base
  • Object
show all
Defined in:
lib/resources/cloudwatch/alarm.rb

Overview

The Alarm class exposes the CloudWatch::Alarm resources

Instance Method Summary collapse

Constructor Details

#initialize(alarm_name, instance = nil) ⇒ Alarm

AWS SDK for Ruby v2 Aws::CloudWatch::Client wrapper for initializing an Alarm resource

Parameters:

  • alarm_name (String)

    The name of the Alarm

  • instance (Class) (defaults to: nil)

    Aws::CloudWatch::Client instance

Raises:

  • (RuntimeError)

    if alarm_name.nil?

  • (RuntimeError)

    if alarms.length == 0

  • (RuntimeError)

    if alarms.length > 1



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

def initialize(alarm_name, instance = nil)
  check_init_arg 'alarm_name', 'CloudWatch::Alarm', alarm_name
  @alarm_name = alarm_name
  @aws = instance.nil? ? Aws::CloudWatch::Client.new : instance
  get_alarm alarm_name
end

Instance Method Details

#actions_enabled?Boolean

Indicates whether actions should be executed during any changes to the Alarm's state

Returns:

  • (Boolean)


35
36
37
# File 'lib/resources/cloudwatch/alarm.rb', line 35

def actions_enabled?
  @alarm.actions_enabled
end

#alarm_actionsArray(String)

The list of actions to execute when this Alarm transitions into an ALARM state from any other state

Returns:

  • (Array(String))


55
56
57
# File 'lib/resources/cloudwatch/alarm.rb', line 55

def alarm_actions
  @alarm.alarm_actions
end

#alarm_descriptionString

The description for the Alarm

Returns:

  • (String)


41
42
43
# File 'lib/resources/cloudwatch/alarm.rb', line 41

def alarm_description
  @alarm.alarm_description
end

#comparison_operatorString

The arithmetic operation to use when comparing the specified Statistic and Threshold

Returns:

  • (String)


119
120
121
# File 'lib/resources/cloudwatch/alarm.rb', line 119

def comparison_operator
  @alarm.comparison_operator
end

#dimensionsArray(Hash{Symbol => String})

The list of dimensions associated with the Alarm's associated metric

Examples:

alarm.dimensions #=>

[
  {
    name: 'The name of the dimension',
    value: 'The value representing the dimension measurement'
  }
]

Returns:

  • (Array(Hash{Symbol => String}))


93
94
95
# File 'lib/resources/cloudwatch/alarm.rb', line 93

def dimensions
  @alarm.dimensions
end

#evaluation_periodsInteger

The number of periods over which data is compared to the specified threshold

Returns:

  • (Integer)


106
107
108
# File 'lib/resources/cloudwatch/alarm.rb', line 106

def evaluation_periods
  @alarm.evaluation_periods
end

#insufficient_data_actionsArray(String)

The list of actions to execute when this Alarm transitions into an INSUFFICIENT_DATA state from any other state

Returns:

  • (Array(String))


62
63
64
# File 'lib/resources/cloudwatch/alarm.rb', line 62

def insufficient_data_actions
  @alarm.insufficient_data_actions
end

#metric_nameString

The name of the Alarm's metric

Returns:

  • (String)


68
69
70
# File 'lib/resources/cloudwatch/alarm.rb', line 68

def metric_name
  @alarm.metric_name
end

#namespaceString

The namespace of Alarm's associated metric

Returns:

  • (String)


74
75
76
# File 'lib/resources/cloudwatch/alarm.rb', line 74

def namespace
  @alarm.namespace
end

#ok?Boolean

Checks if the Alarm state is OK

Returns:

  • (Boolean)


29
30
31
# File 'lib/resources/cloudwatch/alarm.rb', line 29

def ok?
  @alarm.state_value == 'OK'
end

#ok_actionsArray(String)

The list of actions to execute when this Alarm transitions into an OK state from any other state

Returns:

  • (Array(String))


48
49
50
# File 'lib/resources/cloudwatch/alarm.rb', line 48

def ok_actions
  @alarm.ok_actions
end

#periodInteger

The period in seconds over which the statistic is applied

Returns:

  • (Integer)


99
100
101
# File 'lib/resources/cloudwatch/alarm.rb', line 99

def period
  @alarm.period
end

#statisticString

The statistic to apply to the Alarm's associated metric

Returns:

  • (String)


80
81
82
# File 'lib/resources/cloudwatch/alarm.rb', line 80

def statistic
  @alarm.statistic
end

#thresholdNumber

The value against which the specified statistic is compared

Returns:

  • (Number)


112
113
114
# File 'lib/resources/cloudwatch/alarm.rb', line 112

def threshold
  @alarm.threshold
end

#to_sString

Returns the String representation of CloudWatch::Alarmm

Returns:

  • (String)


24
25
26
# File 'lib/resources/cloudwatch/alarm.rb', line 24

def to_s
  "CloudWatch Alarm: #{@alarm_name}"
end