1
- name: Create Alarm 
    ec2_metric_alarm: 
    state: present 
    region: us-west-2 
    name: "Low_On_CPU" 
    metric: "CPUUtilization" 
    namespace: "AWS/EC2" 
    statistic: Average 
    comparison: ">=" 
    threshold: 75.0 
    period: 300 
    evaluation_periods: 1 
    unit: "Percent" 
    description: "The alarm will send notification message when CPU is over 75 percent" 
    alarm_actions: "{{ alarm_action }}" 
    ok_actions: "{{ ok_action }}" 

對於地區:我想爲us-west-2應用雲端警報,但是出現錯誤。其中說:Ansible ec2_metric_alarm區域問題

fatal: [127.0.0.1]: FAILED! => {"changed": false, "failed": true, "msg": "BotoServerError: 400 Bad Request\nhttp://monitoring.amazonaws.com/doc/2010-08-01/\">\n \n Sender\n ValidationError \n Invalid region us-east-1 specified. Only us-west-2 is supported.\n \n fca09709-ad15-11e6-89f8-c1737af27609\n\n"}

當我試圖跟我們東-1相同,它的工作,但與其他地區除美國東部-1不起作用。我對我們也一樣 - 東2,美西1,美西2,但沒有運氣。有關如何解決此問題的任何建議?

+0

我對Ansible不熟悉,但是您發送請求的端點是什麼?要爲us-west-2添加一個指標,您可能必須將API請求發送到us-west-2。這通常是在與AWS連接的軟件中配置的。 –

+0

ansible擁有自己的模塊,使用它可以進行API調用。它使用boto.ec2.cloudwatch創建警報。 – Ketan

+0

對我來說很好。代碼沒有問題。請參閱實際的模塊代碼(https://github.com/ansible/ansible-modules-core/blob/devel/cloud/amazon/ec2_metric_alarm.py#L272-L278),它很簡單且有效。因此,如果您遇到問題,請將錯誤報告提交至https://github.com/ansible/ansible-modules-core。 – BMW

回答

0

澄清來自helloV的評論中的答案。

問題是,alarm_actions的SNS主題與創建警報的區域不同。