From a3488489665e6cc74473510a7354c81a7df53c26 Mon Sep 17 00:00:00 2001 From: xpk Date: Thu, 10 Nov 2022 11:16:24 +0800 Subject: [PATCH] UPD: get sns targets from root module variable --- .../Monitoring.ALB/main.tf | 4 +-- .../Monitoring.ALB/variables.tf | 17 +--------- .../Monitoring.ASG/main.tf | 4 +-- .../Monitoring.ASG/variables.tf | 17 +--------- .../Monitoring.EC2/main.tf | 32 +++++++++---------- .../Monitoring.EC2/variables.tf | 18 ++--------- .../Monitoring.EMR/main.tf | 8 ++--- .../Monitoring.EMR/variables.tf | 17 +--------- .../Monitoring.Kafka/main.tf | 4 +-- .../Monitoring.Kafka/variables.tf | 17 +--------- .../Monitoring.NLB/main.tf | 6 ++-- .../Monitoring.NLB/variables.tf | 17 +--------- .../Monitoring.OpenSearch/main.tf | 16 +++++----- .../Monitoring.OpenSearch/variables.tf | 17 +--------- .../Monitoring.RDS/main.tf | 24 +++++++------- .../Monitoring.RDS/variables.tf | 17 +--------- .../Monitoring.Redis/main.tf | 12 +++---- .../Monitoring.Redis/variables.tf | 17 +--------- 18 files changed, 65 insertions(+), 199 deletions(-) diff --git a/modules/ManagementGovernance/Monitoring.ALB/main.tf b/modules/ManagementGovernance/Monitoring.ALB/main.tf index 7e3f243..c64f5b9 100644 --- a/modules/ManagementGovernance/Monitoring.ALB/main.tf +++ b/modules/ManagementGovernance/Monitoring.ALB/main.tf @@ -18,8 +18,8 @@ resource "aws_cloudwatch_metric_alarm" "alb-HealthyHostCount" { namespace = "AWS/ApplicationELB" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-emergency] - ok_actions = [var.alarm-actions-emergency] + alarm_actions = [var.sns-targets.alarm-actions-emergency] + ok_actions = [var.sns-targets.alarm-actions-emergency] dimensions = { TargetGroup = "targetgroup/${split("/", each.value)[1]}/${split("/", each.value)[2]}" LoadBalancer = "app/${split("/", var.load-balancer)[2]}/${split("/", var.load-balancer)[3]}" diff --git a/modules/ManagementGovernance/Monitoring.ALB/variables.tf b/modules/ManagementGovernance/Monitoring.ALB/variables.tf index 54fa842..35c1740 100644 --- a/modules/ManagementGovernance/Monitoring.ALB/variables.tf +++ b/modules/ManagementGovernance/Monitoring.ALB/variables.tf @@ -2,20 +2,5 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable load-balancer {} variable threshold-HealthHostCountMin {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} \ No newline at end of file diff --git a/modules/ManagementGovernance/Monitoring.ASG/main.tf b/modules/ManagementGovernance/Monitoring.ASG/main.tf index 16e2cb2..74ed3cf 100644 --- a/modules/ManagementGovernance/Monitoring.ASG/main.tf +++ b/modules/ManagementGovernance/Monitoring.ASG/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "asg-CPUUtilization" { namespace = "AWS/EC2" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { AutoScalingGroupName = var.asg-name } diff --git a/modules/ManagementGovernance/Monitoring.ASG/variables.tf b/modules/ManagementGovernance/Monitoring.ASG/variables.tf index 68e5516..f5b70c9 100644 --- a/modules/ManagementGovernance/Monitoring.ASG/variables.tf +++ b/modules/ManagementGovernance/Monitoring.ASG/variables.tf @@ -1,22 +1,7 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable asg-name {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} variable threshold-CPUUtilization {} \ No newline at end of file diff --git a/modules/ManagementGovernance/Monitoring.EC2/main.tf b/modules/ManagementGovernance/Monitoring.EC2/main.tf index f19135e..cd8c891 100644 --- a/modules/ManagementGovernance/Monitoring.EC2/main.tf +++ b/modules/ManagementGovernance/Monitoring.EC2/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-StatusCheckFailed_System" { namespace = "AWS/EC2" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-emergency] - ok_actions = [var.alarm-actions-emergency] + alarm_actions = [var.sns-targets.alarm-actions-emergency] + ok_actions = [var.sns-targets.alarm-actions-emergency] dimensions = { InstanceId = var.ec2-instance-id } @@ -33,8 +33,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-StatusCheckFailed_Instance" { namespace = "AWS/EC2" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-emergency] - ok_actions = [var.alarm-actions-emergency] + alarm_actions = [var.sns-targets.alarm-actions-emergency] + ok_actions = [var.sns-targets.alarm-actions-emergency] dimensions = { InstanceId = var.ec2-instance-id } @@ -56,8 +56,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-CPUUtilization" { namespace = "AWS/EC2" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] treat_missing_data = "notBreaching" dimensions = { InstanceId = var.ec2-instance-id @@ -85,8 +85,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-mem_free" { namespace = "CWAgent" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-standard] - ok_actions = [var.alarm-actions-standard] + alarm_actions = [var.sns-targets.alarm-actions-standard] + ok_actions = [var.sns-targets.alarm-actions-standard] dimensions = { InstanceId = var.ec2-instance-id ImageId = data.aws_instance.ec2-instance.ami @@ -107,8 +107,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-swap_free" { alarm_description = "EC2:swap_free" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-standard] - ok_actions = [var.alarm-actions-standard] + alarm_actions = [var.sns-targets.alarm-actions-standard] + ok_actions = [var.sns-targets.alarm-actions-standard] metric_query { id = "m1" metric { @@ -157,8 +157,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-disk_free" { namespace = "CWAgent" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { InstanceId = var.ec2-instance-id ImageId = data.aws_instance.ec2-instance.ami @@ -186,8 +186,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-disk_inodes_free" { namespace = "CWAgent" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { InstanceId = var.ec2-instance-id ImageId = data.aws_instance.ec2-instance.ami @@ -214,8 +214,8 @@ resource "aws_cloudwatch_metric_alarm" "ec2-processes_total" { namespace = "CWAgent" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { InstanceId = var.ec2-instance-id ImageId = data.aws_instance.ec2-instance.ami diff --git a/modules/ManagementGovernance/Monitoring.EC2/variables.tf b/modules/ManagementGovernance/Monitoring.EC2/variables.tf index 0f99690..0e501f8 100644 --- a/modules/ManagementGovernance/Monitoring.EC2/variables.tf +++ b/modules/ManagementGovernance/Monitoring.EC2/variables.tf @@ -1,22 +1,8 @@ variable "cw-alarm-prefix" {} variable "actions-enabled" {} variable "ec2-instance-id" {} -variable "alarm-actions-urgent" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable "alarm-actions-emergency" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable "alarm-actions-standard" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable "alarm-actions-general" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} + variable "default-tags" {} variable "threshold-CPUUtilization" {} diff --git a/modules/ManagementGovernance/Monitoring.EMR/main.tf b/modules/ManagementGovernance/Monitoring.EMR/main.tf index f973ca3..ca668fa 100644 --- a/modules/ManagementGovernance/Monitoring.EMR/main.tf +++ b/modules/ManagementGovernance/Monitoring.EMR/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "emr-AppsPending" { namespace = "AWS/ElasticMapReduce" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-standard] - ok_actions = [var.alarm-actions-standard] + alarm_actions = [var.sns-targets.alarm-actions-standard] + ok_actions = [var.sns-targets.alarm-actions-standard] dimensions = { JobFlowId = var.job-flow-id } @@ -33,8 +33,8 @@ resource "aws_cloudwatch_metric_alarm" "emr-CapacityRemainingGB" { namespace = "AWS/ElasticMapReduce" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { JobFlowId = var.job-flow-id } diff --git a/modules/ManagementGovernance/Monitoring.EMR/variables.tf b/modules/ManagementGovernance/Monitoring.EMR/variables.tf index a7941bc..0c5959d 100644 --- a/modules/ManagementGovernance/Monitoring.EMR/variables.tf +++ b/modules/ManagementGovernance/Monitoring.EMR/variables.tf @@ -4,20 +4,5 @@ variable job-flow-id {} variable threshold-AppsPending {} variable threshold-CapacityRemainingGB {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} diff --git a/modules/ManagementGovernance/Monitoring.Kafka/main.tf b/modules/ManagementGovernance/Monitoring.Kafka/main.tf index ac8303b..626becb 100644 --- a/modules/ManagementGovernance/Monitoring.Kafka/main.tf +++ b/modules/ManagementGovernance/Monitoring.Kafka/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "Kafka-ZooKeeperRequestLatencyMsMean" { namespace = "AWS/Kafka" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { "Cluster Name" = var.cluster-name } diff --git a/modules/ManagementGovernance/Monitoring.Kafka/variables.tf b/modules/ManagementGovernance/Monitoring.Kafka/variables.tf index 705b0c2..1357dbd 100644 --- a/modules/ManagementGovernance/Monitoring.Kafka/variables.tf +++ b/modules/ManagementGovernance/Monitoring.Kafka/variables.tf @@ -1,22 +1,7 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable cluster-name {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} variable threshold-ZooKeeperRequestLatencyMsMean {} diff --git a/modules/ManagementGovernance/Monitoring.NLB/main.tf b/modules/ManagementGovernance/Monitoring.NLB/main.tf index 86e0c5d..b49bc0b 100644 --- a/modules/ManagementGovernance/Monitoring.NLB/main.tf +++ b/modules/ManagementGovernance/Monitoring.NLB/main.tf @@ -17,7 +17,7 @@ module "nlb-targetgroups" { resource "aws_cloudwatch_metric_alarm" "nlb-HealthyHostCount" { for_each = module.nlb-targetgroups.result-set alarm_name = "${var.cw-alarm-prefix}:NLBTG:HealthyHostCount:${split(":", each.value)[5]}" - comparison_operator = "LessThanOrEqualToThreshold" + comparison_operator = "LessThanThreshold" evaluation_periods = "1" metric_name = "HealthyHostCount" period = "300" @@ -27,8 +27,8 @@ resource "aws_cloudwatch_metric_alarm" "nlb-HealthyHostCount" { namespace = "AWS/NetworkELB" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-emergency] - ok_actions = [var.alarm-actions-emergency] + alarm_actions = [var.sns-targets.alarm-actions-emergency] + ok_actions = [var.sns-targets.alarm-actions-emergency] dimensions = { TargetGroup = split(":", each.value)[5] LoadBalancer = "net/${split("/", var.load-balancer)[2]}/${split("/", var.load-balancer)[3]}" diff --git a/modules/ManagementGovernance/Monitoring.NLB/variables.tf b/modules/ManagementGovernance/Monitoring.NLB/variables.tf index 54fa842..35c1740 100644 --- a/modules/ManagementGovernance/Monitoring.NLB/variables.tf +++ b/modules/ManagementGovernance/Monitoring.NLB/variables.tf @@ -2,20 +2,5 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable load-balancer {} variable threshold-HealthHostCountMin {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} \ No newline at end of file diff --git a/modules/ManagementGovernance/Monitoring.OpenSearch/main.tf b/modules/ManagementGovernance/Monitoring.OpenSearch/main.tf index 57dff7b..19e97d0 100644 --- a/modules/ManagementGovernance/Monitoring.OpenSearch/main.tf +++ b/modules/ManagementGovernance/Monitoring.OpenSearch/main.tf @@ -12,8 +12,8 @@ resource "aws_cloudwatch_metric_alarm" "ES-CPUUtilization" { namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id @@ -36,8 +36,8 @@ resource "aws_cloudwatch_metric_alarm" "ES-SearchLatency" { namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id @@ -60,8 +60,8 @@ resource "aws_cloudwatch_metric_alarm" "ES-IndexingLatency" { namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id @@ -84,8 +84,8 @@ resource "aws_cloudwatch_metric_alarm" "ES-ClusterStatusRed" { namespace = "AWS/ES" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DomainName = var.domain-name ClientId = data.aws_caller_identity.this.id diff --git a/modules/ManagementGovernance/Monitoring.OpenSearch/variables.tf b/modules/ManagementGovernance/Monitoring.OpenSearch/variables.tf index 28100c4..28d9fdb 100644 --- a/modules/ManagementGovernance/Monitoring.OpenSearch/variables.tf +++ b/modules/ManagementGovernance/Monitoring.OpenSearch/variables.tf @@ -1,22 +1,7 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable domain-name {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} variable threshold-CPUUtilization {} diff --git a/modules/ManagementGovernance/Monitoring.RDS/main.tf b/modules/ManagementGovernance/Monitoring.RDS/main.tf index d2c1254..1030cb3 100644 --- a/modules/ManagementGovernance/Monitoring.RDS/main.tf +++ b/modules/ManagementGovernance/Monitoring.RDS/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-cpu" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } @@ -33,8 +33,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-storage" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } @@ -56,8 +56,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-memory" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } @@ -79,8 +79,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-DiskQueueDepth" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } @@ -102,8 +102,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-ReadLatency" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } @@ -125,8 +125,8 @@ resource "aws_cloudwatch_metric_alarm" "rds-WriteLatency" { namespace = "AWS/RDS" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { DBInstanceIdentifier = var.rds-instance-name } diff --git a/modules/ManagementGovernance/Monitoring.RDS/variables.tf b/modules/ManagementGovernance/Monitoring.RDS/variables.tf index a919c48..a6e9c9e 100644 --- a/modules/ManagementGovernance/Monitoring.RDS/variables.tf +++ b/modules/ManagementGovernance/Monitoring.RDS/variables.tf @@ -1,22 +1,7 @@ variable cw-alarm-prefix {} variable actions-enabled {} variable rds-instance-name {} -variable alarm-actions-urgent { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable alarm-actions-emergency { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable alarm-actions-standard { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable alarm-actions-general { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable default-tags {} variable threshold-FreeableMemory {} diff --git a/modules/ManagementGovernance/Monitoring.Redis/main.tf b/modules/ManagementGovernance/Monitoring.Redis/main.tf index ab0bbcf..bcb208a 100644 --- a/modules/ManagementGovernance/Monitoring.Redis/main.tf +++ b/modules/ManagementGovernance/Monitoring.Redis/main.tf @@ -10,8 +10,8 @@ resource "aws_cloudwatch_metric_alarm" "redis-EngineCPUUtilization" { namespace = "AWS/ElastiCache" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { CacheClusterId = var.redis-cluster-id } @@ -33,8 +33,8 @@ resource "aws_cloudwatch_metric_alarm" "redis-DatabaseMemoryUsagePercentage" { namespace = "AWS/ElastiCache" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-urgent] - ok_actions = [var.alarm-actions-urgent] + alarm_actions = [var.sns-targets.alarm-actions-urgent] + ok_actions = [var.sns-targets.alarm-actions-urgent] dimensions = { CacheClusterId = var.redis-cluster-id } @@ -56,8 +56,8 @@ resource "aws_cloudwatch_metric_alarm" "redis-CacheHitRate" { namespace = "AWS/ElastiCache" insufficient_data_actions = [] actions_enabled = var.actions-enabled - alarm_actions = [var.alarm-actions-standard] - ok_actions = [var.alarm-actions-standard] + alarm_actions = [var.sns-targets.alarm-actions-standard] + ok_actions = [var.sns-targets.alarm-actions-standard] dimensions = { CacheClusterId = var.redis-cluster-id # CacheNodeId = each.value diff --git a/modules/ManagementGovernance/Monitoring.Redis/variables.tf b/modules/ManagementGovernance/Monitoring.Redis/variables.tf index 13e69d2..dc06b4f 100644 --- a/modules/ManagementGovernance/Monitoring.Redis/variables.tf +++ b/modules/ManagementGovernance/Monitoring.Redis/variables.tf @@ -1,22 +1,7 @@ variable cw-alarm-prefix {} variable "actions-enabled" {} variable "redis-cluster-id" {} -variable "alarm-actions-urgent" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-urgent" -} -variable "alarm-actions-emergency" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-emergency" -} -variable "alarm-actions-standard" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support-standard" -} -variable "alarm-actions-general" { - type = string - default = "arn:aws:sns:ap-east-1:843733946244:rackspace-support" -} +variable sns-targets {} variable "default-tags" {} variable "threshold-EngineCPUUtilization" {}