- name: create scale down alarm
ec2_metric_alarm:
state: present
region: "{{ region }}"
name: "cpu-low"
metric: CPUUtilization
namespace: "AWS/EC2"
statistic: Average
comparison: "<="
threshold: 5.0
period: 300
evaluation_periods: 3
unit: "Percent"
description: "This will alarm when cpu usage average is lower than 5% for 15 minutes "
dimensions:
AutoScalingGroupName: "{{ app_name }}"
alarm_actions:
- "{{ scale_down_policy.arn }}"
tags: alarm
Attempting to run this playbook as-is results in the following error:
argument threshold is of invalid type: <type 'int'>, required: float
This is due to the threshold variable in the "create scale down alarm" play being cast automatically as "int" instead of float. This can be resolved by ensuring the value of threshold is in decimal form, i.e. "5.0"
roles/infra/tasks/main.yml
Attempting to run this playbook as-is results in the following error:
argument threshold is of invalid type: <type 'int'>, required: float
This is due to the
threshold
variable in the "create scale down alarm" play being cast automatically as "int" instead of float. This can be resolved by ensuring the value ofthreshold
is in decimal form, i.e. "5.0"