# ec2\_metric\_alarm Not Recognizing retries Parameter

**URL:** <https://forum.ansible.com/t/ec2-metric-alarm-not-recognizing-retries-parameter/24230>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [April 17, 2017, 8:44pm UTC](https://forum.ansible.com/t/ec2-metric-alarm-not-recognizing-retries-parameter/24230 "2017-04-17T20:44:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse\_DeRose](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jesse\_DeRose](https://forum.ansible.com/u/Jesse_DeRose)\
**Post date:** [April 17, 2017, 8:44pm UTC](https://forum.ansible.com/t/ec2-metric-alarm-not-recognizing-retries-parameter/24230/1 "2017-04-17T20:44:38Z")

</div>

I’m currently using the ec2\_metric\_alarm module to create a CloudWatch alarm. Due to AWS API throttling, the task generally fails during its first try and must be retried with the “retries” parameter. My code looks something like this:

`

- name: create alarm  
ec2\_metric\_alarm:  
state: present  
region: us-east-1  
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 a bamboo slave’s cpu usage average is lower than 5% for 15 minutes "  
dimensions: {‘InstanceId’:‘i-XXX’}  
alarm\_actions: [“action1”,“action2”]  
retries: 5  
delay: 30

`

When I actually run the playbook, I get this error:

`

14:00:30 TASK [Create CloudWatch alarm - CPU] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
14:00:30 task path: /path/to/task.yml:91  
14:00:31 Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/cloud/amazon/ec2\_metric\_alarm.py  
14:00:31 ESTABLISH LOCAL CONNECTION FOR USER: tools  
14:00:31 EXEC /bin/sh -c ‘/usr/bin/python && sleep 0’  
14:00:31 fatal: [localhost]: FAILED! =\> {  
14:00:31 “changed”: false,  
14:00:31 “failed”: true,  
14:00:31 “invocation”: {  
14:00:31 “module\_args”: {  
14:00:31 “alarm\_actions”: [  
14:00:31 “path-to-policy-arn”  
14:00:31 ],  
14:00:31 “aws\_access\_key”: null,  
14:00:31 “aws\_secret\_key”: null,  
14:00:31 “comparison”: “\>=”,  
14:00:31 “description”: "This will alarm when a bamboo slave’s cpu usage average is lower than 5% for 15 minutes “,  
14:00:31 “dimensions”: {  
14:00:31 “InstanceId”: “i-XXX”  
14:00:31 },  
14:00:31 “ec2\_url”: null,  
14:00:31 “evaluation\_periods”: 3,  
14:00:31 “insufficient\_data\_actions”: null,  
14:00:31 “metric”: “CPUUtilization”,  
14:00:31 “name”: “cpu-low”,  
14:00:31 “namespace”: “AWS/EC2”,  
14:00:31 “ok\_actions”: null,  
14:00:31 “period”: 300,  
14:00:31 “profile”: null,  
14:00:31 “region”: “us-east-1”,  
14:00:31 “security\_token”: null,  
14:00:31 “state”: “present”,  
14:00:31 “statistic”: “Average”,  
14:00:31 “threshold”: 5.0,  
14:00:31 “unit”: “Percent”,  
14:00:31 “validate\_certs”: true  
14:00:31 },  
14:00:31 “module\_name”: “ec2\_metric\_alarm”  
14:00:31 },  
14:00:31 “msg”: “BotoServerError: 400 Bad Request\n\<ErrorResponse xmlns="[http://monitoring.amazonaws.com/doc/2010-08-01/\](http://monitoring.amazonaws.com/doc/2010-08-01/%5C)”\>\n \n Sender\n `Throttling`\n Rate exceeded\n \n bf38e4d8-2397-11e7-b197-c31f0855aa5d\n\n”  
14:00:31 }

`

So it looks like Ansible isn’t actually recognizing the retries/delay parameters at all, and fatally erroring out at the first failed attempt of the task. I’ve already spoken with AWS support and they won’t lift/change the throttling bandwidth. I looked through the Ansible GH issues list and found this related issue, but couldn’t get their suggested workaround to work for me: [https://github.com/ansible/ansible-modules-core/issues/143](https://github.com/ansible/ansible-modules-core/issues/143)

Any ideas as to why the playbook isn’t recognizing/using the retries/delay parameters here? Or any workaround suggestions?
