aws_cloudwatch

Prishita Kapoor
2 min readApr 11, 2022

Use this resource to manage CloudWatch alarms.

Actions

  • create - Create or update CloudWatch alarms.
  • delete - Delete CloudWatch alarms.
  • disable_action - Disable action of the CloudWatch alarms.
  • enable_action - Enable action of the CloudWatch alarms.

Properties

  • aws_secret_access_key, aws_access_key and optionally aws_session_token - required, unless using IAM roles for authentication.
  • alarm_name - the alarm name. If none is given on assignment, will take the resource name.
  • alarm_description - the description of alarm. Can be blank also.
  • actions_enabled - true for enable action on OK, ALARM or Insufficient data. if true, any of ok_actions, alarm_actions or insufficient_data_actions must be specified.
  • ok_actions - array of action if alarm state is OK. If specified actions_enabled must be true.
  • alarm_actions - array of action if alarm state is ALARM. If specified actions_enabled must be true.
  • insufficient_data_actions - array of action if alarm state is INSUFFICIENT_DATA. If specified actions_enabled must be true.
  • metric_name - CloudWatch metric name of the alarm. eg - CPUUtilization.Required parameter.
  • namespace - namespace of the alarm. eg - AWS/EC2, required parameter.
  • statistic - statistic of the alarm. Value must be in any of SampleCount, Average, Sum, Minimum or Maximum. Required parameter.
  • extended_statistic - extended_statistic of the alarm. Specify a value between p0.0 and p100. Optional parameter.
  • dimensions - dimensions for the metric associated with the alarm. Array of name and value.
  • period - in seconds, over which the specified statistic is applied. Integer type and required parameter.
  • unit - unit of measure for the statistic. Required parameter.
  • evaluation_periods - number of periods over which data is compared to the specified threshold. Required parameter.
  • threshold - value against which the specified statistic is compared. Can be float or integer type. Required parameter.
  • comparison_operator - arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand.

For more information about parameters, see CloudWatch Identifiers in the Using CloudWatch guide.

Examples

aws_cloudwatch "kitchen_test_alarm" do
period 21600
evaluation_periods 2
threshold 50.0
comparison_operator "LessThanThreshold"
metric_name "CPUUtilization"
namespace "AWS/EC2"
statistic "Maximum"
dimensions [{"name" : "InstanceId", "value" : "i-xxxxxxx"}]
action :create
end

--

--

Prishita Kapoor

I endeavor to fuse academic knowledge with experience for the growth of the world while enhancing my engineering and interpersonal skills.