Skip to content

Commit ffc8b5f

Browse files
author
aknysh
committed
Assign attributes and tags from variables.tf to label module
1 parent 7fbc512 commit ffc8b5f

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44

55
# Module directory
66
.terraform/
7+
8+
.idea
9+
*.iml

main.tf

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# Define composite variables for resources
22
module "label" {
3-
source = "git::https://github.com/cloudposse/tf_label.git?ref=tags/0.1.0"
4-
namespace = "${var.namespace}"
5-
name = "${var.name}"
6-
stage = "${var.stage}"
3+
source = "git::https://github.com/cloudposse/tf_label.git?ref=tags/0.2.0"
4+
namespace = "${var.namespace}"
5+
name = "${var.name}"
6+
stage = "${var.stage}"
7+
delimiter = "${var.delimiter}"
8+
attributes = "${var.attributes}"
9+
tags = "${var.tags}"
710
}
811

912
#
@@ -26,11 +29,7 @@ resource "aws_security_group" "default" {
2629
cidr_blocks = ["0.0.0.0/0"]
2730
}
2831

29-
tags {
30-
Name = "${module.label.id}"
31-
Namespace = "${var.namespace}"
32-
Stage = "${var.stage}"
33-
}
32+
tags = "${module.label.tags}"
3433
}
3534

3635
resource "aws_elasticache_subnet_group" "default" {
@@ -57,7 +56,7 @@ resource "aws_elasticache_replication_group" "default" {
5756
maintenance_window = "${var.maintenance_window}"
5857
notification_topic_arn = "${var.notification_topic_arn}"
5958

60-
tags = "${module.label.tags}"
59+
tags = "${module.label.tags}"
6160
}
6261

6362
#
@@ -73,14 +72,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
7372
period = "300"
7473
statistic = "Average"
7574

76-
threshold = "${var.alarm_cpu_threshold_percent}"
75+
threshold = "${var.alarm_cpu_threshold_percent}"
7776

7877
dimensions {
7978
CacheClusterId = "${module.label.id}"
8079
}
8180

82-
alarm_actions = ["${var.alarm_actions}"]
83-
depends_on = ["aws_elasticache_replication_group.default"]
81+
alarm_actions = ["${var.alarm_actions}"]
82+
depends_on = ["aws_elasticache_replication_group.default"]
83+
tags = "${module.label.tags}"
8484
}
8585

8686
resource "aws_cloudwatch_metric_alarm" "cache_memory" {
@@ -93,14 +93,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" {
9393
period = "60"
9494
statistic = "Average"
9595

96-
threshold = "${var.alarm_memory_threshold_bytes}"
96+
threshold = "${var.alarm_memory_threshold_bytes}"
9797

9898
dimensions {
9999
CacheClusterId = "${module.label.id}"
100100
}
101101

102-
alarm_actions = ["${var.alarm_actions}"]
103-
depends_on = ["aws_elasticache_replication_group.default"]
102+
alarm_actions = ["${var.alarm_actions}"]
103+
depends_on = ["aws_elasticache_replication_group.default"]
104+
tags = "${module.label.tags}"
104105
}
105106

106107

variables.tf

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ variable "cluster_size" {
3131
default = "1"
3232
}
3333

34-
3534
variable "port" {
3635
default = "6379"
3736
}
3837

39-
4038
variable "instance_type" {
4139
default = "cache.t2.micro"
4240
}
@@ -80,3 +78,18 @@ variable "availability_zones" {
8078
}
8179

8280
variable "zone_id" {}
81+
82+
variable "delimiter" {
83+
type = "string"
84+
default = "-"
85+
}
86+
87+
variable "attributes" {
88+
type = "list"
89+
default = []
90+
}
91+
92+
variable "tags" {
93+
type = "map"
94+
default = {}
95+
}

0 commit comments

Comments
 (0)