Skip to content

Commit

Permalink
Add security group name (terraform-aws-modules#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
akofman committed Apr 10, 2020
1 parent 742b75f commit 9e334cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
locals {
port = "${var.port == "" ? "${var.engine == "aurora-postgresql" ? "5432" : "3306"}" : var.port}"
master_password = "${var.password == "" ? random_id.master_password.b64 : var.password}"
db_subnet_group_name = "${var.db_subnet_group_name == "" ? join("", aws_db_subnet_group.this.*.name) : var.db_subnet_group_name}"
backtrack_window = "${var.backtrack_window == "" ? "${var.engine == "aurora" ? "0" : ""}" : var.backtrack_window}"
}

Expand All @@ -10,6 +11,8 @@ resource "random_id" "master_password" {
}

resource "aws_db_subnet_group" "this" {
count = "${var.db_subnet_group_name == "" ? 1 : 0}"

name = "${var.name}"
description = "For Aurora cluster ${var.name}"
subnet_ids = ["${var.subnets}"]
Expand All @@ -36,7 +39,7 @@ resource "aws_rds_cluster" "this" {
preferred_backup_window = "${var.preferred_backup_window}"
preferred_maintenance_window = "${var.preferred_maintenance_window}"
port = "${local.port}"
db_subnet_group_name = "${aws_db_subnet_group.this.name}"
db_subnet_group_name = "${local.db_subnet_group_name}"
vpc_security_group_ids = ["${concat(list(aws_security_group.this.id), var.vpc_security_group_ids)}"]
scaling_configuration = "${var.scaling_configuration}"
snapshot_identifier = "${var.snapshot_identifier}"
Expand All @@ -60,7 +63,7 @@ resource "aws_rds_cluster_instance" "this" {
engine_version = "${var.engine_version}"
instance_class = "${var.instance_type}"
publicly_accessible = "${var.publicly_accessible}"
db_subnet_group_name = "${aws_db_subnet_group.this.name}"
db_subnet_group_name = "${local.db_subnet_group_name}"
db_parameter_group_name = "${var.db_parameter_group_name}"
preferred_maintenance_window = "${var.preferred_maintenance_window}"
apply_immediately = "${var.apply_immediately}"
Expand Down
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ variable "vpc_security_group_ids" {
default = []
}

variable "db_subnet_group_name" {
description = "The existing subnet group name to use"
default = ""
}

variable "backtrack_window" {
description = "The target backtrack window, in seconds. Only available for aurora engine currently. To disable backtracking, set this value to 0. Defaults to 0. Must be between 0 and 259200 (72 hours)"
default = "0"
Expand Down

0 comments on commit 9e334cf

Please sign in to comment.