From b42d373706d529e0d8064f9c661416c96c569256 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 2 Jul 2021 00:07:05 -0400 Subject: [PATCH 1/8] Update main.tf Modified alarm name and id based on project name .${var.project} --- main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index cd327d2..0510ffc 100644 --- a/main.tf +++ b/main.tf @@ -41,7 +41,7 @@ resource "aws_elasticache_replication_group" "redis" { resource "aws_cloudwatch_metric_alarm" "cache_cpu" { count = "${var.desired_clusters}" - alarm_name = "alarm${var.environment}CacheCluster00${count.index + 1}CPUUtilization" + alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}CPUUtilization" alarm_description = "Redis cluster CPU utilization" comparison_operator = "GreaterThanThreshold" evaluation_periods = "1" @@ -62,7 +62,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" { resource "aws_cloudwatch_metric_alarm" "cache_memory" { count = "${var.desired_clusters}" - alarm_name = "alarm${var.environment}CacheCluster00${count.index + 1}FreeableMemory" + alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}FreeableMemory" alarm_description = "Redis cluster freeable memory" comparison_operator = "LessThanThreshold" evaluation_periods = "1" From c5aefcca599c7b60d7bdf3c866d3e2dc95795b6c Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Thu, 8 Jul 2021 23:44:28 -0400 Subject: [PATCH 2/8] Update main.tf --- main.tf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.tf b/main.tf index 0510ffc..2634708 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,7 @@ resource "aws_security_group" "redis" { vpc_id = "${var.vpc_id}" tags { - Name = "sgCacheCluster" + Name = "${var.project}-${var.environment}-sgCacheCluster" Project = "${var.project}" Environment = "${var.environment}" } @@ -29,7 +29,7 @@ resource "aws_elasticache_replication_group" "redis" { port = "6379" tags { - Name = "CacheReplicationGroup" + Name = "${var.project}-${var.environment}-CacheReplicationGroup" Project = "${var.project}" Environment = "${var.environment}" } @@ -42,7 +42,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" { count = "${var.desired_clusters}" alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}CPUUtilization" - alarm_description = "Redis cluster CPU utilization" + alarm_description = "${var.project} ${var.environment} Redis cluster CPU utilization" comparison_operator = "GreaterThanThreshold" evaluation_periods = "1" metric_name = "CPUUtilization" @@ -53,7 +53,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" { threshold = "${var.alarm_cpu_threshold}" dimensions { - CacheClusterId = "${aws_elasticache_replication_group.redis.id}-00${count.index + 1}" + CacheClusterId = "${var.environment}-${aws_elasticache_replication_group.redis.id}-00${count.index + 1}" } alarm_actions = ["${var.alarm_actions}"] @@ -63,7 +63,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" { count = "${var.desired_clusters}" alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}FreeableMemory" - alarm_description = "Redis cluster freeable memory" + alarm_description = "${var.project} ${var.environment} Redis cluster freeable memory" comparison_operator = "LessThanThreshold" evaluation_periods = "1" metric_name = "FreeableMemory" @@ -74,7 +74,7 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" { threshold = "${var.alarm_memory_threshold}" dimensions { - CacheClusterId = "${aws_elasticache_replication_group.redis.id}-00${count.index + 1}" + CacheClusterId = "${var.environment}-${aws_elasticache_replication_group.redis.id}-00${count.index + 1}" } alarm_actions = ["${var.alarm_actions}"] From 07b3acfa3dcf2d1032967374031346bb7db16316 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:04:33 -0400 Subject: [PATCH 3/8] Update main.tf --- main.tf | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/main.tf b/main.tf index 2634708..90673b1 100644 --- a/main.tf +++ b/main.tf @@ -4,11 +4,14 @@ resource "aws_security_group" "redis" { vpc_id = "${var.vpc_id}" - tags { - Name = "${var.project}-${var.environment}-sgCacheCluster" - Project = "${var.project}" - Environment = "${var.environment}" - } + tags = merge( + { + "Name" = "${var.project}-${var.environment}-sgCacheCluster", + "Project" = "${var.project}", + "Environment" = "${var.environment}" + }, + var.tags, + ) } # From 8d22792ed6a8be5c0ca63350be1f9646e7fa85f5 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:05:14 -0400 Subject: [PATCH 4/8] Update variables.tf --- variables.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/variables.tf b/variables.tf index 84bb11a..243f8dd 100644 --- a/variables.tf +++ b/variables.tf @@ -34,6 +34,12 @@ variable "automatic_failover_enabled" { default = false } +variable "tags" { + description = "common tags associated with resource" + type = map(string) + default = {} +} + variable "notification_topic_arn" {} variable "alarm_cpu_threshold" { From ad5957f3d5ecae3ab5251050876b91ce924ae94b Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:12:08 -0400 Subject: [PATCH 5/8] Update main.tf --- main.tf | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 90673b1..654806d 100644 --- a/main.tf +++ b/main.tf @@ -6,10 +6,14 @@ resource "aws_security_group" "redis" { tags = merge( { - "Name" = "${var.project}-${var.environment}-sgCacheCluster", - "Project" = "${var.project}", - "Environment" = "${var.environment}" + "Name" = "${var.project}-${var.environment}-sgCacheCluster" + }, + { + "Project" = "${var.project}" }, + { + "Environment" = "${var.environment}" + }, var.tags, ) } From a6883616513598bdd791e3561b59560c107ad346 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:23:09 -0400 Subject: [PATCH 6/8] Update main.tf --- main.tf | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/main.tf b/main.tf index 654806d..9b8a8bd 100644 --- a/main.tf +++ b/main.tf @@ -4,18 +4,12 @@ resource "aws_security_group" "redis" { vpc_id = "${var.vpc_id}" - tags = merge( - { - "Name" = "${var.project}-${var.environment}-sgCacheCluster" - }, - { - "Project" = "${var.project}" - }, - { - "Environment" = "${var.environment}" - }, - var.tags, - ) + tags { + Name = "sgCacheCluster" + Project = "${var.project}" + Environment = "${var.environment}" + owner = "${var.owner}" + } } # From b99416f55d1fdfed6a3d5db22601dc1deef34899 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:25:40 -0400 Subject: [PATCH 7/8] Update variables.tf --- variables.tf | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/variables.tf b/variables.tf index 243f8dd..d9058f9 100644 --- a/variables.tf +++ b/variables.tf @@ -34,11 +34,7 @@ variable "automatic_failover_enabled" { default = false } -variable "tags" { - description = "common tags associated with resource" - type = map(string) - default = {} -} +variable "owner" {} variable "notification_topic_arn" {} From e0ee988298c9646b567d10cd74d07254e414e474 Mon Sep 17 00:00:00 2001 From: rajaskumar <74214534+rajaskumar@users.noreply.github.com> Date: Fri, 9 Jul 2021 00:30:27 -0400 Subject: [PATCH 8/8] Update main.tf --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index 9b8a8bd..438a583 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,7 @@ resource "aws_security_group" "redis" { vpc_id = "${var.vpc_id}" tags { - Name = "sgCacheCluster" + Name = "${var.project}-${var.environment}-sgCacheCluster" Project = "${var.project}" Environment = "${var.environment}" owner = "${var.owner}"