@@ -19,6 +19,7 @@ module "labels" {
1919# Module : Elasticache Subnet Group
2020# Description : Terraform module which creates Subnet Group for Elasticache.
2121resource "aws_elasticache_subnet_group" "default" {
22+ count = var. enable ? 1 : 0
2223 name = module. labels . id
2324 subnet_ids = var. subnet_ids
2425 description = " Managed by Clouddrove"
@@ -27,7 +28,7 @@ resource "aws_elasticache_subnet_group" "default" {
2728# Module : Elasticache Replication Group
2829# Description : Terraform module which creates standalone instance for Elasticache Redis.
2930resource "aws_elasticache_replication_group" "default" {
30- count = var. replication_enabled ? 1 : 0
31+ count = var. enable && var . replication_enabled ? 1 : 0
3132 engine = var. engine
3233 replication_group_id = module. labels . id
3334 replication_group_description = module. labels . id
@@ -36,7 +37,7 @@ resource "aws_elasticache_replication_group" "default" {
3637 parameter_group_name = " default.redis5.0"
3738 node_type = var. node_type
3839 automatic_failover_enabled = var. automatic_failover_enabled
39- subnet_group_name = aws_elasticache_subnet_group. default . name
40+ subnet_group_name = join ( " " , aws_elasticache_subnet_group. default . * . name )
4041 security_group_ids = var. security_group_ids
4142 security_group_names = var. security_group_names
4243 snapshot_arns = var. snapshot_arns
@@ -58,7 +59,7 @@ resource "aws_elasticache_replication_group" "default" {
5859# Module : Elasticache Replication Group
5960# Description : Terraform module which creates cluster for Elasticache Redis.
6061resource "aws_elasticache_replication_group" "cluster" {
61- count = var. cluster_replication_enabled ? 1 : 0
62+ count = var. enable && var . cluster_replication_enabled ? 1 : 0
6263 engine = var. engine
6364 replication_group_id = module. labels . id
6465 replication_group_description = module. labels . id
@@ -67,7 +68,7 @@ resource "aws_elasticache_replication_group" "cluster" {
6768 parameter_group_name = " default.redis5.0.cluster.on"
6869 node_type = var. node_type
6970 automatic_failover_enabled = var. automatic_failover_enabled
70- subnet_group_name = aws_elasticache_subnet_group. default . name
71+ subnet_group_name = join ( " " , aws_elasticache_subnet_group. default . * . name )
7172 security_group_ids = var. security_group_ids
7273 security_group_names = var. security_group_names
7374 snapshot_arns = var. snapshot_arns
@@ -92,7 +93,7 @@ resource "aws_elasticache_replication_group" "cluster" {
9293# Module : Elasticache Cluster
9394# Description : Terraform module which creates cluster for Elasticache Memcached.
9495resource "aws_elasticache_cluster" "default" {
95- count = var. cluster_enabled ? 1 : 0
96+ count = var. enable && var . cluster_enabled ? 1 : 0
9697 engine = var. engine
9798 cluster_id = module. labels . id
9899 engine_version = var. engine_version
@@ -101,7 +102,7 @@ resource "aws_elasticache_cluster" "default" {
101102 az_mode = var. az_mode
102103 parameter_group_name = " default.memcached1.5"
103104 node_type = var. node_type
104- subnet_group_name = aws_elasticache_subnet_group. default . name
105+ subnet_group_name = join ( " " , aws_elasticache_subnet_group. default . * . name )
105106 security_group_ids = var. security_group_ids
106107 security_group_names = var. security_group_names
107108 snapshot_arns = var. snapshot_arns
0 commit comments