Skip to content

Commit

Permalink
Enable db_subnet_group_name variable (terraform-aws-modules#38)
Browse files Browse the repository at this point in the history
* ✨ Enable db_subnet_group_name variable

If the variable not specify then use the db_subnet_group module

* Disable create_db_subnet_group if db_subnet_group_name is defined
  • Loading branch information
mhdali authored and antonbabenko committed Feb 9, 2018
1 parent 8a5af3e commit f681318
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 7 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
locals {
db_subnet_group_name = "${coalesce(var.db_subnet_group_name, module.db_subnet_group.this_db_subnet_group_id)}"
enable_create_db_subnet_group = "${var.db_subnet_group_name == "" ? var.create_db_subnet_group : 0}"
}

##################
# DB subnet group
##################
module "db_subnet_group" {
source = "./modules/db_subnet_group"

count = "${var.create_db_subnet_group}"
count = "${local.enable_create_db_subnet_group}"
identifier = "${var.identifier}"
name_prefix = "${var.identifier}-"
subnet_ids = ["${var.subnet_ids}"]
Expand Down Expand Up @@ -56,7 +61,7 @@ module "db_instance" {
snapshot_identifier = "${var.snapshot_identifier}"

vpc_security_group_ids = ["${var.vpc_security_group_ids}"]
db_subnet_group_name = "${module.db_subnet_group.this_db_subnet_group_id}"
db_subnet_group_name = "${local.db_subnet_group_name}"
parameter_group_name = "${module.db_parameter_group.this_db_parameter_group_id}"

multi_az = "${var.multi_az}"
Expand Down
10 changes: 5 additions & 5 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ variable "vpc_security_group_ids" {
default = []
}

//variable "db_subnet_group_name" {
// description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC"
// default = ""
//}
//
variable "db_subnet_group_name" {
description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC"
default = ""
}

//variable "parameter_group_name" {
// description = "Name of the DB parameter group to associate"
// default = ""
Expand Down

0 comments on commit f681318

Please sign in to comment.