Я пытаюсь использовать ansible модуль ec2_metric_alarm, чтобы создавать аварийные сигналы состояния экземпляра для моих экземпляров EC2, но я продолжаю получать сообщение об ошибке «AlarmName не должно содержать начальные или конечные пробелы», не уверен, что я делаю неправильно, я здесьЯ не использую пробелы в моем имени будильника, но все равно получаю ту же ошибку. Любое предложение будет оценено.
Вот мой код:
- name: Create Instance Check Alarm
ec2_metric_alarm:
state: present
security_token: "{{security_token}}"
region: "{{region}}"
name: "{{cluster_name}}_StatusCheckFailed_Instance_{{new_instance_id}}"
metric: "StatusCheckFailed_Instance"
namespace: "AWS/EC2"
statistic: "Maximum"
evaluation_periods: 2
comparison: ">="
threshold: 1.0
period: 60
unit: "Count"
description: "This will alarm will Reboot Instance when there is a Instance Check fails"
dimensions: {'InstanceId': "{{new_instance_id}}"}
alarm_actions: ["arn:aws:sns:{{region}}:SNS_TOPIC:NotifyMe","arn:aws:automate:{{region}}:ec2:reboot"]
delegate_to: localhost
- name: Create System Fail Alarm
ec2_metric_alarm:
state: present
security_token: "{{security_token}}"
region: "{{region}}"
name: "{{cluster_name}}_StatusCheckFailed_Instance_{{new_instance_id}}"
metric: "StatusCheckFailed_System"
namespace: "AWS/EC2"
statistic: "Maximum"
evaluation_periods: 2
comparison: ">="
threshold: 1.0
period: 60
unit: "Count"
description: "This will alarm will Auto Recover Instance when there is a System Failure Identified"
dimensions: {'InstanceId': "{{new_instance_id}}"}
alarm_actions: ["arn:aws:sns:{{region}}:SNS_TOPIC:NotifyMe","arn:aws:automate:{{region}}:ec2:recover"]
delegate_to: localhost
The full traceback is:
Traceback (most recent call last):
File "/uhome/user/.ansible/tmp/ansible-tmp-1573183650.92-219299995957066/AnsiballZ_ec2_metric_alarm.py", line 113, in <module>
_ansiballz_main()
File "/uhome/user/.ansible/tmp/ansible-tmp-1573183650.92-219299995957066/AnsiballZ_ec2_metric_alarm.py", line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/uhome/user/.ansible/tmp/ansible-tmp-1573183650.92-219299995957066/AnsiballZ_ec2_metric_alarm.py", line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File "/tmp/ansible_ec2_metric_alarm_payload_F0yFcU/__main__.py", line 320, in <module>
File "/tmp/ansible_ec2_metric_alarm_payload_F0yFcU/__main__.py", line 314, in main
File "/tmp/ansible_ec2_metric_alarm_payload_F0yFcU/__main__.py", line 171, in create_metric_alarm
File "/uhome/user/lib/python2.7/site-packages/boto/ec2/cloudwatch/__init__.py", line 382, in describe_alarms
[('MetricAlarms', MetricAlarms)])
File "/uhome/user/lib/python2.7/site-packages/boto/connection.py", line 1186, in get_list
raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
<Error>
<Type>Sender</Type>
<Code>ValidationError</Code>
<Message>AlarmName must not contain leading or trailing whitespace</Message>
</Error>
<RequestId>ab8f10ca-d9cd-4964-945e-34727c77a09a</RequestId>
</ErrorResponse>