Skip to content

Commit 9b1c6f0

Browse files
author
Sharp Hall
committed
Merge branch 'release/0.3.0'
2 parents e5fb082 + 00e3a85 commit 9b1c6f0

File tree

3 files changed

+57
-37
lines changed

3 files changed

+57
-37
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.3.0
2+
3+
- Add cache name to alarm names so multiple instances do not conflict within
4+
the same AWS account.
5+
- Apply hclfmt.
6+
17
## 0.2.0
28

39
- Remove hardcoded identifiers and interpolate the new `cache_name` variable to

main.tf

+37-32
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ resource "aws_security_group" "redis" {
66
vpc_id = "${var.vpc_id}"
77

88
ingress {
9-
from_port = 6379
10-
to_port = 6379
11-
protocol = "tcp"
9+
from_port = 6379
10+
to_port = 6379
11+
protocol = "tcp"
1212
cidr_blocks = ["${var.vpc_cidr_block}"]
1313
}
1414

1515
egress {
16-
from_port = 6379
17-
to_port = 6379
18-
protocol = "tcp"
16+
from_port = 6379
17+
to_port = 6379
18+
protocol = "tcp"
1919
cidr_blocks = ["${var.vpc_cidr_block}"]
2020
}
2121

@@ -29,61 +29,66 @@ resource "aws_security_group" "redis" {
2929
#
3030

3131
resource "aws_elasticache_cluster" "redis" {
32-
cluster_id = "${var.cache_name}"
33-
engine = "redis"
34-
engine_version = "${var.engine_version}"
35-
maintenance_window = "${var.maintenance_window}"
36-
node_type = "${var.instance_type}"
37-
num_cache_nodes = "1"
32+
cluster_id = "${var.cache_name}"
33+
engine = "redis"
34+
engine_version = "${var.engine_version}"
35+
maintenance_window = "${var.maintenance_window}"
36+
node_type = "${var.instance_type}"
37+
num_cache_nodes = "1"
3838
parameter_group_name = "default.redis2.8"
39-
port = "6379"
40-
subnet_group_name = "${aws_elasticache_subnet_group.default.name}"
41-
security_group_ids = ["${aws_security_group.redis.id}"]
39+
port = "6379"
40+
subnet_group_name = "${aws_elasticache_subnet_group.default.name}"
41+
security_group_ids = ["${aws_security_group.redis.id}"]
4242

4343
tags {
4444
Name = "CacheCluster"
4545
}
4646
}
4747

4848
resource "aws_elasticache_subnet_group" "default" {
49-
name = "${var.cache_name}-subnet-group"
49+
name = "${var.cache_name}-subnet-group"
5050
description = "Private subnets for the ElastiCache instances"
51-
subnet_ids = ["${split(",", var.private_subnet_ids)}"]
51+
subnet_ids = ["${split(",", var.private_subnet_ids)}"]
5252
}
5353

5454
#
5555
# CloudWatch resources
5656
#
5757

5858
resource "aws_cloudwatch_metric_alarm" "cpu" {
59-
alarm_name = "alarmCacheClusterCPUUtilization"
60-
alarm_description = "Cache cluster CPU utilization"
59+
alarm_name = "alarmCacheClusterCPUUtilization-${var.cache_name}"
60+
alarm_description = "Cache cluster CPU utilization"
6161
comparison_operator = "GreaterThanThreshold"
62-
evaluation_periods = "1"
63-
metric_name = "CPUUtilization"
64-
namespace = "AWS/ElastiCache"
65-
period = "300"
66-
statistic = "Average"
67-
threshold = "75"
62+
evaluation_periods = "1"
63+
metric_name = "CPUUtilization"
64+
namespace = "AWS/ElastiCache"
65+
period = "300"
66+
statistic = "Average"
67+
threshold = "75"
68+
6869
dimensions {
6970
CacheClusterId = "${aws_elasticache_cluster.redis.id}"
7071
}
72+
7173
alarm_actions = ["${split(",", var.alarm_actions)}"]
7274
}
7375

7476
resource "aws_cloudwatch_metric_alarm" "memory_free" {
75-
alarm_name = "alarmCacheClusterFreeableMemory"
76-
alarm_description = "Cache cluster freeable memory"
77+
alarm_name = "alarmCacheClusterFreeableMemory-${var.cache_name}"
78+
alarm_description = "Cache cluster freeable memory"
7779
comparison_operator = "LessThanThreshold"
78-
evaluation_periods = "1"
79-
metric_name = "FreeableMemory"
80-
namespace = "AWS/ElastiCache"
81-
period = "60"
82-
statistic = "Average"
80+
evaluation_periods = "1"
81+
metric_name = "FreeableMemory"
82+
namespace = "AWS/ElastiCache"
83+
period = "60"
84+
statistic = "Average"
85+
8386
# 10MB in bytes
8487
threshold = "10000000"
88+
8589
dimensions {
8690
CacheClusterId = "${aws_elasticache_cluster.redis.id}"
8791
}
92+
8893
alarm_actions = ["${split(",", var.alarm_actions)}"]
8994
}

variables.tf

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
1-
variable "vpc_id" { }
2-
variable "vpc_cidr_block" { }
1+
variable "vpc_id" {
2+
}
3+
4+
variable "vpc_cidr_block" {
5+
}
6+
7+
variable "cache_name" {
8+
}
39

4-
variable "cache_name" { }
510
variable "engine_version" {
611
default = "2.8.22"
712
}
13+
814
variable "instance_type" {
915
default = "cache.t2.micro"
1016
}
17+
1118
variable "maintenance_window" {
1219
# SUN 01:00AM-02:00AM ET
1320
default = "sun:05:00-sun:06:00"
1421
}
1522

16-
variable "private_subnet_ids" { }
23+
variable "private_subnet_ids" {
24+
}
1725

18-
variable "alarm_actions" { }
26+
variable "alarm_actions" {
27+
}

0 commit comments

Comments
 (0)