Skip to content

Commit

Permalink
update example.tf and added coustom tags with tag variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbysinghh committed Dec 2, 2021
1 parent 1def13a commit 6405934
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 17 deletions.
35 changes: 34 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*




# ignored files
*.tfstate
*.tfstate.backup
.terraform
.idea
*.iml
*.terraform.lock.hcl
*.terraform.lock.hcl
1 change: 1 addition & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ usage : |-
engine = "memcached"
engine_version = "1.5.10"
family = "memcached1.5"
parameter_group_name = "default.memcached1.5"
az_mode = "cross-az"
port = 11211
node_type = "cache.t2.micro"
Expand Down
26 changes: 15 additions & 11 deletions _example/memcached/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ module "memcached" {
environment = "test"
label_order = ["name", "environment"]

cluster_enabled = true
engine = "memcached"
engine_version = "1.5.10"
family = "memcached1.5"
az_mode = "cross-az"
port = 11211
node_type = "cache.t2.micro"
num_cache_nodes = 2
subnet_ids = module.subnets.public_subnet_id
security_group_ids = [module.memcached-sg.security_group_ids]
availability_zones = ["eu-west-1a", "eu-west-1b"]
cluster_enabled = true
engine = "memcached"
engine_version = "1.5.10"
family = "memcached1.5"
parameter_group_name = "default.memcached1.5"
az_mode = "cross-az"
port = 11211
node_type = "cache.t2.micro"
num_cache_nodes = 2
subnet_ids = module.subnets.public_subnet_id
security_group_ids = [module.memcached-sg.security_group_ids]
availability_zones = ["eu-west-1a", "eu-west-1b"]
tags = {
org = "test"
}
}
6 changes: 6 additions & 0 deletions _example/memcached/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ output "tags" {
value = module.memcached.tags
description = "A mapping of tags to assign to the resource."
}

output "memcached_endpoint" {
value = module.memcached.memcached_endpoint
description = "Memcached endpoint address."
}

3 changes: 3 additions & 0 deletions _example/redis-cluster/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ module "redis-cluster" {
replicas_per_node_group = 2
num_node_groups = 1
automatic_failover_enabled = true
tags = {
org = "test"
}
}
7 changes: 6 additions & 1 deletion _example/redis-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
output "id" {
value = module.redis-cluster.*.id
value = module.redis-cluster.id
description = "Redis cluster id."
}

output "tags" {
value = module.redis-cluster.tags
description = "A mapping of tags to assign to the resource."
}

output "redis_endpoint" {
value = module.redis-cluster.redis_endpoint
description = "Redis endpoint address."
}
3 changes: 3 additions & 0 deletions _example/redis/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,7 @@ module "redis" {
availability_zones = ["eu-west-1a", "eu-west-1b"]
auto_minor_version_upgrade = true
number_cache_clusters = 2
tags = {
org = "test"
}
}
5 changes: 5 additions & 0 deletions _example/redis/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ output "tags" {
value = module.redis.tags
description = "A mapping of tags to assign to the resource."
}

output "redis_endpoint" {
value = module.redis.redis_endpoint
description = "Redis endpoint address."
}
9 changes: 6 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ resource "aws_elasticache_subnet_group" "default" {
name = module.labels.id
subnet_ids = var.subnet_ids
description = var.description

tags = merge(var.tags, module.labels.tags)
}

# Module : Elasticache Replication Group
Expand Down Expand Up @@ -57,7 +59,8 @@ resource "aws_elasticache_replication_group" "default" {
transit_encryption_enabled = var.transit_encryption_enabled
auth_token = var.auth_token
kms_key_id = var.kms_key_id
tags = module.labels.tags
tags = merge(var.tags, module.labels.tags)

}

# Module : Elasticache Replication Group
Expand Down Expand Up @@ -88,7 +91,7 @@ resource "aws_elasticache_replication_group" "cluster" {
transit_encryption_enabled = var.transit_encryption_enabled
auth_token = var.auth_token
kms_key_id = var.kms_key_id
tags = module.labels.tags
tags = merge(var.tags, module.labels.tags)
cluster_mode {
replicas_per_node_group = var.replicas_per_node_group #Replicas per Shard
num_node_groups = var.num_node_groups #Number of Shards
Expand Down Expand Up @@ -118,5 +121,5 @@ resource "aws_elasticache_cluster" "default" {
apply_immediately = var.apply_immediately
preferred_availability_zones = slice(var.availability_zones, 0, var.num_cache_nodes)
maintenance_window = var.maintenance_window
tags = module.labels.tags
tags = merge(var.tags, module.labels.tags)
}
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ output "port" {
}

output "tags" {
value = module.labels.tags
value = merge(var.tags, module.labels.tags)
description = "A mapping of tags to assign to the resource."
}

Expand Down

0 comments on commit 6405934

Please sign in to comment.