Skip to content

Commit 6405934

Browse files
committed
update example.tf and added coustom tags with tag variable
1 parent 1def13a commit 6405934

File tree

10 files changed

+80
-17
lines changed

10 files changed

+80
-17
lines changed

.gitignore

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Crash log files
9+
crash.log
10+
11+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12+
# .tfvars files are managed as part of configuration and so should be included in
13+
# version control.
14+
#
15+
# example.tfvars
16+
17+
# Ignore override files as they are usually used to override resources locally and so
18+
# are not checked in
19+
override.tf
20+
override.tf.json
21+
*_override.tf
22+
*_override.tf.json
23+
24+
# Include override files you do wish to add to version control using negated pattern
25+
#
26+
# !example_override.tf
27+
28+
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
29+
# example: *tfplan*
30+
31+
32+
33+
134
# ignored files
235
*.tfstate
336
*.tfstate.backup
437
.terraform
538
.idea
639
*.iml
7-
*.terraform.lock.hcl
40+
*.terraform.lock.hcl

README.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ usage : |-
9191
engine = "memcached"
9292
engine_version = "1.5.10"
9393
family = "memcached1.5"
94+
parameter_group_name = "default.memcached1.5"
9495
az_mode = "cross-az"
9596
port = 11211
9697
node_type = "cache.t2.micro"

_example/memcached/example.tf

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ module "memcached" {
5050
environment = "test"
5151
label_order = ["name", "environment"]
5252

53-
cluster_enabled = true
54-
engine = "memcached"
55-
engine_version = "1.5.10"
56-
family = "memcached1.5"
57-
az_mode = "cross-az"
58-
port = 11211
59-
node_type = "cache.t2.micro"
60-
num_cache_nodes = 2
61-
subnet_ids = module.subnets.public_subnet_id
62-
security_group_ids = [module.memcached-sg.security_group_ids]
63-
availability_zones = ["eu-west-1a", "eu-west-1b"]
53+
cluster_enabled = true
54+
engine = "memcached"
55+
engine_version = "1.5.10"
56+
family = "memcached1.5"
57+
parameter_group_name = "default.memcached1.5"
58+
az_mode = "cross-az"
59+
port = 11211
60+
node_type = "cache.t2.micro"
61+
num_cache_nodes = 2
62+
subnet_ids = module.subnets.public_subnet_id
63+
security_group_ids = [module.memcached-sg.security_group_ids]
64+
availability_zones = ["eu-west-1a", "eu-west-1b"]
65+
tags = {
66+
org = "test"
67+
}
6468
}

_example/memcached/outputs.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ output "tags" {
22
value = module.memcached.tags
33
description = "A mapping of tags to assign to the resource."
44
}
5+
6+
output "memcached_endpoint" {
7+
value = module.memcached.memcached_endpoint
8+
description = "Memcached endpoint address."
9+
}
10+

_example/redis-cluster/example.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,7 @@ module "redis-cluster" {
6161
replicas_per_node_group = 2
6262
num_node_groups = 1
6363
automatic_failover_enabled = true
64+
tags = {
65+
org = "test"
66+
}
6467
}

_example/redis-cluster/outputs.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
output "id" {
2-
value = module.redis-cluster.*.id
2+
value = module.redis-cluster.id
33
description = "Redis cluster id."
44
}
55

66
output "tags" {
77
value = module.redis-cluster.tags
88
description = "A mapping of tags to assign to the resource."
99
}
10+
11+
output "redis_endpoint" {
12+
value = module.redis-cluster.redis_endpoint
13+
description = "Redis endpoint address."
14+
}

_example/redis/example.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,7 @@ module "redis" {
5858
availability_zones = ["eu-west-1a", "eu-west-1b"]
5959
auto_minor_version_upgrade = true
6060
number_cache_clusters = 2
61+
tags = {
62+
org = "test"
63+
}
6164
}

_example/redis/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ output "tags" {
77
value = module.redis.tags
88
description = "A mapping of tags to assign to the resource."
99
}
10+
11+
output "redis_endpoint" {
12+
value = module.redis.redis_endpoint
13+
description = "Redis endpoint address."
14+
}

main.tf

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ resource "aws_elasticache_subnet_group" "default" {
2626
name = module.labels.id
2727
subnet_ids = var.subnet_ids
2828
description = var.description
29+
30+
tags = merge(var.tags, module.labels.tags)
2931
}
3032

3133
# Module : Elasticache Replication Group
@@ -57,7 +59,8 @@ resource "aws_elasticache_replication_group" "default" {
5759
transit_encryption_enabled = var.transit_encryption_enabled
5860
auth_token = var.auth_token
5961
kms_key_id = var.kms_key_id
60-
tags = module.labels.tags
62+
tags = merge(var.tags, module.labels.tags)
63+
6164
}
6265

6366
# Module : Elasticache Replication Group
@@ -88,7 +91,7 @@ resource "aws_elasticache_replication_group" "cluster" {
8891
transit_encryption_enabled = var.transit_encryption_enabled
8992
auth_token = var.auth_token
9093
kms_key_id = var.kms_key_id
91-
tags = module.labels.tags
94+
tags = merge(var.tags, module.labels.tags)
9295
cluster_mode {
9396
replicas_per_node_group = var.replicas_per_node_group #Replicas per Shard
9497
num_node_groups = var.num_node_groups #Number of Shards
@@ -118,5 +121,5 @@ resource "aws_elasticache_cluster" "default" {
118121
apply_immediately = var.apply_immediately
119122
preferred_availability_zones = slice(var.availability_zones, 0, var.num_cache_nodes)
120123
maintenance_window = var.maintenance_window
121-
tags = module.labels.tags
124+
tags = merge(var.tags, module.labels.tags)
122125
}

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ output "port" {
1212
}
1313

1414
output "tags" {
15-
value = module.labels.tags
15+
value = merge(var.tags, module.labels.tags)
1616
description = "A mapping of tags to assign to the resource."
1717
}
1818

0 commit comments

Comments
 (0)