diff options
author | Spike <avlampson+git@gmail.com> | 2019-04-07 22:03:31 +0100 |
---|---|---|
committer | Spike <avlampson+git@gmail.com> | 2019-04-07 22:03:31 +0100 |
commit | bb81085619769aca861ab5d5bbff86f71c9435d2 (patch) | |
tree | 80b45de34d9f0647c10e6d6fae5b408c21c190c5 /cloudwatch.tf | |
download | fundapp_demo-bb81085619769aca861ab5d5bbff86f71c9435d2.zip fundapp_demo-bb81085619769aca861ab5d5bbff86f71c9435d2.tar.gz fundapp_demo-bb81085619769aca861ab5d5bbff86f71c9435d2.tar.bz2 |
Diffstat (limited to 'cloudwatch.tf')
-rw-r--r-- | cloudwatch.tf | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cloudwatch.tf b/cloudwatch.tf new file mode 100644 index 0000000..9a73918 --- /dev/null +++ b/cloudwatch.tf @@ -0,0 +1,45 @@ +resource "aws_cloudwatch_metric_alarm" "target_healthy_count" { + alarm_name = "ELB-target-healthy-count" + comparison_operator = "LessThanOrEqualToThreshold" + evaluation_periods = "1" + metric_name = "HealthyHostCount" + period = "60" + statistic = "Average" + threshold = "0" + + dimensions { + LoadBalancer = "${aws_elb.app_elb.id}" + } + + alarm_description = "Trigger an alert when elb has 1 or more unhealthy hosts" + + #alarm_actions = "Would point at sns here" + #ok_actions = "Would also point at sns" + treat_missing_data = "breaching" +} + +resource "aws_autoscaling_policy" "app_as_policy" { + name = "app_autoscaling_policy" + scaling_adjustment = 1 + adjustment_type = "ChangeInCapacity" + cooldown = 300 + autoscaling_group_name = "${aws_autoscaling_group.app_asg.name}" +} + +resource "aws_cloudwatch_metric_alarm" "app_asg_alarm" { + alarm_name = "app_asg_alarm" + comparison_operator = "GreaterThanOrEqualToThreshold" + evaluation_periods = "2" + metric_name = "CPUUtilization" + namespace = "AWS/EC2" + period = "120" + statistic = "Average" + threshold = "80" + + dimensions = { + AutoScalingGroupName = "${aws_autoscaling_group.app_asg.name}" + } + + alarm_description = "This metric monitors ec2 cpu utilization" + alarm_actions = ["${aws_autoscaling_policy.app_as_policy.arn}"] +} |