Skip to content

Instantly share code, notes, and snippets.

@bbhenry
Created October 2, 2015 16:58
Show Gist options
  • Save bbhenry/970ae597758d8ee5d2a7 to your computer and use it in GitHub Desktop.
Save bbhenry/970ae597758d8ee5d2a7 to your computer and use it in GitHub Desktop.
- name: Get instance ec2 facts
action: ec2_facts
register: ec2_facts
- name: Get resource tags from ec2 facts
sudo: false
local_action: ec2_tag resource={{ec2_facts.ansible_facts.ansible_ec2_instance_id}} region=us-east-1 state=list
register: result
- name: Create CPU utilization metric alarm
sudo: false
local_action: ec2_metric_alarm state=present region=us-east-1 name="{{result.Name}}-cpu-utilization" metric="CPUUtilization" statistic=Average comparison=">=" threshold=80.0 unit="Percent" period=300 evaluation_periods=1 description="It will be triggered when CPU utilization is more than 80% for 5 minutes" dimensions="InstanceId"="{{ec2_facts.ansible_facts.ansible_ec2_instance_id}}" alarm_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification ok_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment