Commit 27f72db9 authored by Andriy Knysh's avatar Andriy Knysh Committed by GitHub

Merge pull request #3 from cloudposse/add-attributes-and-tags

Assign `attributes` and `tags` from `variables.tf` to `label` module
parents 7fbc5129 ffc8b5f8
...@@ -4,3 +4,6 @@ ...@@ -4,3 +4,6 @@
# Module directory # Module directory
.terraform/ .terraform/
.idea
*.iml
# Define composite variables for resources # Define composite variables for resources
module "label" { module "label" {
source = "git::https://github.com/cloudposse/tf_label.git?ref=tags/0.1.0" source = "git::https://github.com/cloudposse/tf_label.git?ref=tags/0.2.0"
namespace = "${var.namespace}" namespace = "${var.namespace}"
name = "${var.name}" name = "${var.name}"
stage = "${var.stage}" stage = "${var.stage}"
delimiter = "${var.delimiter}"
attributes = "${var.attributes}"
tags = "${var.tags}"
} }
# #
...@@ -26,11 +29,7 @@ resource "aws_security_group" "default" { ...@@ -26,11 +29,7 @@ resource "aws_security_group" "default" {
cidr_blocks = ["0.0.0.0/0"] cidr_blocks = ["0.0.0.0/0"]
} }
tags { tags = "${module.label.tags}"
Name = "${module.label.id}"
Namespace = "${var.namespace}"
Stage = "${var.stage}"
}
} }
resource "aws_elasticache_subnet_group" "default" { resource "aws_elasticache_subnet_group" "default" {
...@@ -57,7 +56,7 @@ resource "aws_elasticache_replication_group" "default" { ...@@ -57,7 +56,7 @@ resource "aws_elasticache_replication_group" "default" {
maintenance_window = "${var.maintenance_window}" maintenance_window = "${var.maintenance_window}"
notification_topic_arn = "${var.notification_topic_arn}" notification_topic_arn = "${var.notification_topic_arn}"
tags = "${module.label.tags}" tags = "${module.label.tags}"
} }
# #
...@@ -73,14 +72,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" { ...@@ -73,14 +72,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_cpu" {
period = "300" period = "300"
statistic = "Average" statistic = "Average"
threshold = "${var.alarm_cpu_threshold_percent}" threshold = "${var.alarm_cpu_threshold_percent}"
dimensions { dimensions {
CacheClusterId = "${module.label.id}" CacheClusterId = "${module.label.id}"
} }
alarm_actions = ["${var.alarm_actions}"] alarm_actions = ["${var.alarm_actions}"]
depends_on = ["aws_elasticache_replication_group.default"] depends_on = ["aws_elasticache_replication_group.default"]
tags = "${module.label.tags}"
} }
resource "aws_cloudwatch_metric_alarm" "cache_memory" { resource "aws_cloudwatch_metric_alarm" "cache_memory" {
...@@ -93,14 +93,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" { ...@@ -93,14 +93,15 @@ resource "aws_cloudwatch_metric_alarm" "cache_memory" {
period = "60" period = "60"
statistic = "Average" statistic = "Average"
threshold = "${var.alarm_memory_threshold_bytes}" threshold = "${var.alarm_memory_threshold_bytes}"
dimensions { dimensions {
CacheClusterId = "${module.label.id}" CacheClusterId = "${module.label.id}"
} }
alarm_actions = ["${var.alarm_actions}"] alarm_actions = ["${var.alarm_actions}"]
depends_on = ["aws_elasticache_replication_group.default"] depends_on = ["aws_elasticache_replication_group.default"]
tags = "${module.label.tags}"
} }
......
...@@ -31,12 +31,10 @@ variable "cluster_size" { ...@@ -31,12 +31,10 @@ variable "cluster_size" {
default = "1" default = "1"
} }
variable "port" { variable "port" {
default = "6379" default = "6379"
} }
variable "instance_type" { variable "instance_type" {
default = "cache.t2.micro" default = "cache.t2.micro"
} }
...@@ -80,3 +78,18 @@ variable "availability_zones" { ...@@ -80,3 +78,18 @@ variable "availability_zones" {
} }
variable "zone_id" {} variable "zone_id" {}
variable "delimiter" {
type = "string"
default = "-"
}
variable "attributes" {
type = "list"
default = []
}
variable "tags" {
type = "map"
default = {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment