From 73fe1815838073d5120358020a1ad151918e45f4 Mon Sep 17 00:00:00 2001 From: Justin Wind Date: Wed, 15 Nov 2017 11:22:49 -0800 Subject: [PATCH] add a basic cw alarm --- infrastructure/modules/management-stack/alarms.tf | 13 +++++++++++++ infrastructure/modules/management-stack/iam.tf | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/infrastructure/modules/management-stack/alarms.tf b/infrastructure/modules/management-stack/alarms.tf index c278d19..3e244fb 100644 --- a/infrastructure/modules/management-stack/alarms.tf +++ b/infrastructure/modules/management-stack/alarms.tf @@ -29,3 +29,16 @@ resource "aws_cloudwatch_metric_alarm" "failures-present" { } alarm_actions = ["${aws_sns_topic.management-alerts.arn}"] } + +resource "aws_cloudwatch_metric_alarm" "unhealthy" { + alarm_name = "UnhealthyHostCount" + alarm_description = "Alert when any ELB has unhealthy hosts." + metric_name = "UnHealthyHostCount" + comparison_operator = "GreaterThanOrEqualToThreshold" + evaluation_periods = 15 + period = 60 + namespace = "AWS/ELB" + statistic = "Maximum" + threshold = 1 + alarm_actions = ["${aws_sns_topic.management-alerts.arn}"] +} \ No newline at end of file diff --git a/infrastructure/modules/management-stack/iam.tf b/infrastructure/modules/management-stack/iam.tf index 3f85134..78783a1 100644 --- a/infrastructure/modules/management-stack/iam.tf +++ b/infrastructure/modules/management-stack/iam.tf @@ -23,10 +23,15 @@ data "aws_iam_policy_document" "management" { sid = "AWSControl" actions = [ "autoscaling:*", + "cloudwatch:ListMetrics", + "cloudwatch:GetMetricStatistics", + "cloudwatch:Describe*", "ec2:*", "elasticloadbalancing:*", "iam:PassRole", - "iam:GetServerCertificate" + "iam:GetServerCertificate", + "logs:DescribeLogStreams", + "logs:PutLogEvents", ] resources = [ "*" -- 2.45.2