Skip to content
This repository was archived by the owner on Oct 8, 2022. It is now read-only.

Modified alarm_name in the module #24

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ 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}"
}
}

#
Expand All @@ -29,7 +30,7 @@ resource "aws_elasticache_replication_group" "redis" {
port = "6379"

tags {
Name = "CacheReplicationGroup"
Name = "${var.project}-${var.environment}-CacheReplicationGroup"
Project = "${var.project}"
Environment = "${var.environment}"
}
Expand All @@ -41,8 +42,8 @@ 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_description = "Redis cluster CPU utilization"
alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}CPUUtilization"
alarm_description = "${var.project} ${var.environment} Redis cluster CPU utilization"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "1"
metric_name = "CPUUtilization"
Expand All @@ -53,7 +54,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}"]
Expand All @@ -62,8 +63,8 @@ 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_description = "Redis cluster freeable memory"
alarm_name = "alarm${var.project}${var.environment}CacheCluster00${count.index + 1}FreeableMemory"
alarm_description = "${var.project} ${var.environment} Redis cluster freeable memory"
comparison_operator = "LessThanThreshold"
evaluation_periods = "1"
metric_name = "FreeableMemory"
Expand All @@ -74,7 +75,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}"]
Expand Down
2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ variable "automatic_failover_enabled" {
default = false
}

variable "owner" {}

variable "notification_topic_arn" {}

variable "alarm_cpu_threshold" {
Expand Down