Skip to content

Commit 8a293e7

Browse files
committed
Added possibility to control creation of elasticache and redshift subnet groups
1 parent 4e484aa commit 8a293e7

File tree

4 files changed

+22
-10
lines changed

4 files changed

+22
-10
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ Terraform version 0.10.3 or newer is required for this module to work.
186186
| create\_database\_internet\_gateway\_route | Controls if an internet gateway route for public database access should be created | string | `false` | no |
187187
| create\_database\_subnet\_group | Controls if database subnet group should be created | string | `true` | no |
188188
| create\_database\_subnet\_route\_table | Controls if separate route table for database should be created | string | `false` | no |
189+
| create\_elasticache\_subnet\_group | Controls if elasticache subnet group should be created | string | `true` | no |
189190
| create\_elasticache\_subnet\_route\_table | Controls if separate route table for elasticache should be created | string | `false` | no |
191+
| create\_redshift\_subnet\_group | Controls if redshift subnet group should be created | string | `true` | no |
190192
| create\_redshift\_subnet\_route\_table | Controls if separate route table for redshift should be created | string | `false` | no |
191193
| create\_vpc | Controls if VPC should be created (it affects almost all resources) | string | `true` | no |
192194
| database\_route\_table\_tags | Additional tags for the database route tables | map | `{}` | no |
@@ -255,7 +257,7 @@ Terraform version 0.10.3 or newer is required for this module to work.
255257

256258
| Name | Description |
257259
|------|-------------|
258-
| azs | A list of availability zones spefified as argument to this module |
260+
| azs | A list of availability zones specified as argument to this module |
259261
| database\_route\_table\_ids | List of IDs of database route tables |
260262
| database\_subnet\_group | ID of database subnet group |
261263
| database\_subnets | List of IDs of database subnets |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ resource "aws_subnet" "redshift" {
230230
}
231231

232232
resource "aws_redshift_subnet_group" "redshift" {
233-
count = "${var.create_vpc && length(var.redshift_subnets) > 0 ? 1 : 0}"
233+
count = "${var.create_vpc && length(var.redshift_subnets) > 0 && var.create_redshift_subnet_group ? 1 : 0}"
234234

235235
name = "${lower(var.name)}"
236236
description = "Redshift subnet group for ${var.name}"
@@ -253,7 +253,7 @@ resource "aws_subnet" "elasticache" {
253253
}
254254

255255
resource "aws_elasticache_subnet_group" "elasticache" {
256-
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 ? 1 : 0}"
256+
count = "${var.create_vpc && length(var.elasticache_subnets) > 0 && var.create_elasticache_subnet_group ? 1 : 0}"
257257

258258
name = "${var.name}"
259259
description = "ElastiCache subnet group for ${var.name}"

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,6 @@ output "default_vpc_main_route_table_id" {
279279
//}
280280

281281
output "azs" {
282-
description = "A list of availability zones spefified as argument to this module"
282+
description = "A list of availability zones specified as argument to this module"
283283
value = "${var.azs}"
284284
}

variables.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ variable "elasticache_subnets" {
8181
default = []
8282
}
8383

84+
variable "intra_subnets" {
85+
type = "list"
86+
description = "A list of intra subnets"
87+
default = []
88+
}
89+
8490
variable "create_database_subnet_route_table" {
8591
description = "Controls if separate route table for database should be created"
8692
default = false
@@ -96,17 +102,21 @@ variable "create_elasticache_subnet_route_table" {
96102
default = false
97103
}
98104

99-
variable "intra_subnets" {
100-
type = "list"
101-
description = "A list of intra subnets"
102-
default = []
103-
}
104-
105105
variable "create_database_subnet_group" {
106106
description = "Controls if database subnet group should be created"
107107
default = true
108108
}
109109

110+
variable "create_elasticache_subnet_group" {
111+
description = "Controls if elasticache subnet group should be created"
112+
default = true
113+
}
114+
115+
variable "create_redshift_subnet_group" {
116+
description = "Controls if redshift subnet group should be created"
117+
default = true
118+
}
119+
110120
variable "create_database_internet_gateway_route" {
111121
description = "Controls if an internet gateway route for public database access should be created"
112122
default = false

0 commit comments

Comments
 (0)