Here is my ansible-script to create alarms and notification through ec2_metric_alarm module. I can successfully create the scaling part, but I cannot able to create the SNS notification.
- name: Create or delete AWS metric alarms metrics you wish to alarm on must already exists
local_action:
module: ec2_metric_alarm
region: us-east-1
name: “{{ item.name }}”
state: present
metric: “CPUUtilization”
namespace: “AWS/EC2”
statistic: “Average”
comparison: “{{ item.comparison }}”
threshold: “{{ item.threshold }}”
period: 60
evaluation_periods: 3
unit: “Percent”
dimensions:
AutoScalingGroupName: “testing-ASG”
alarm_actions: “{{ item.alarm_actions }}”
with_items:
- name: “testing-SCALE-UP”
comparison: “>=”
threshold: 70.0
alarm_actions:
-
“{{ autoscaling.results[0].arn }}”
-
arn:aws:sns:us-east-1:465404434664:Polanotify
-
name: “testing-SCALE-DOWN”
comparison: “<=”
threshold: 20.0
alarm_actions:
-
“{{ autoscaling.results[1].arn }}”
-
arn:aws:sns:us-east-1:465404434664:Polanotify
here is the error I am getting:
[u’arn:aws:autoscaling:us-east-1:465404434664:scalingPolicy:267c5e14-e272-4e16-9d8f-88544e9ca4ca:autoScalingGroupName/testing-ASG:policyName/Increase Group Size’, u’arn:aws:sns:us-east-1:465404434664:Polanotify’], u’name’: u’testing-SCALE-UP’}) => {“failed”: true, “item”: {“alarm_actions”: [“arn:aws:autoscaling:us-east-1:465404434664:scalingPolicy:267c5e14-e272-4e16-9d8f-88544e9ca4ca:autoScalingGroupName/testing-ASG:policyName/Increase Group Size”, “arn:aws:sns:us-east-1:465404434664:Polanotify”], “comparison”: “>=”, “name”: “testing-SCALE-UP”, “threshold”: 70.0}, “msg”: “BotoServerError: 400 Bad Request\n<ErrorResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/\”>\n \n Sender\n ValidationError
\n Invalid arn syntax: [‘arn:aws:autoscaling:us-east-1:465404434664:scalingPolicy:267c5e14-e272-4e16-9d8f-88544e9ca4ca:autoScalingGroupName/testing-ASG:policyName/Increase Group Size’, ‘arn:aws:sns:us-east-1:465404434664:Polar1notify’]\n \n 8df5ae3d-c528-11e5-9f41-2352ce248144\n\n"}
What could be the possible problem ?