Skip to content

Commit

Permalink
Merge pull request #199 from terraform-aws-modules/elasticache_subnet…
Browse files Browse the repository at this point in the history
…_group

Added possibility to control creation of elasticache and redshift subnet groups
  • Loading branch information
antonbabenko authored Jan 10, 2019
2 parents 4e484aa + 8a293e7 commit c9bfc7e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ Terraform version 0.10.3 or newer is required for this module to work.
| create\_database\_internet\_gateway\_route | Controls if an internet gateway route for public database access should be created | string | `false` | no |
| create\_database\_subnet\_group | Controls if database subnet group should be created | string | `true` | no |
| create\_database\_subnet\_route\_table | Controls if separate route table for database should be created | string | `false` | no |
| create\_elasticache\_subnet\_group | Controls if elasticache subnet group should be created | string | `true` | no |
| create\_elasticache\_subnet\_route\_table | Controls if separate route table for elasticache should be created | string | `false` | no |
| create\_redshift\_subnet\_group | Controls if redshift subnet group should be created | string | `true` | no |
| create\_redshift\_subnet\_route\_table | Controls if separate route table for redshift should be created | string | `false` | no |
| create\_vpc | Controls if VPC should be created (it affects almost all resources) | string | `true` | no |
| database\_route\_table\_tags | Additional tags for the database route tables | map | `{}` | no |
Expand Down Expand Up @@ -255,7 +257,7 @@ Terraform version 0.10.3 or newer is required for this module to work.

| Name | Description |
|------|-------------|
| azs | A list of availability zones spefified as argument to this module |
| azs | A list of availability zones specified as argument to this module |
| database\_route\_table\_ids | List of IDs of database route tables |
| database\_subnet\_group | ID of database subnet group |
| database\_subnets | List of IDs of database subnets |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ resource "aws_subnet" "redshift" {
}

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

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

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

name = "${var.name}"
description = "ElastiCache subnet group for ${var.name}"
Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,6 @@ output "default_vpc_main_route_table_id" {
//}

output "azs" {
description = "A list of availability zones spefified as argument to this module"
description = "A list of availability zones specified as argument to this module"
value = "${var.azs}"
}
22 changes: 16 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ variable "elasticache_subnets" {
default = []
}

variable "intra_subnets" {
type = "list"
description = "A list of intra subnets"
default = []
}

variable "create_database_subnet_route_table" {
description = "Controls if separate route table for database should be created"
default = false
Expand All @@ -96,17 +102,21 @@ variable "create_elasticache_subnet_route_table" {
default = false
}

variable "intra_subnets" {
type = "list"
description = "A list of intra subnets"
default = []
}

variable "create_database_subnet_group" {
description = "Controls if database subnet group should be created"
default = true
}

variable "create_elasticache_subnet_group" {
description = "Controls if elasticache subnet group should be created"
default = true
}

variable "create_redshift_subnet_group" {
description = "Controls if redshift subnet group should be created"
default = true
}

variable "create_database_internet_gateway_route" {
description = "Controls if an internet gateway route for public database access should be created"
default = false
Expand Down

0 comments on commit c9bfc7e

Please sign in to comment.