Skip to content

Commit

Permalink
Merge pull request #6 from stakater/final-snapshot
Browse files Browse the repository at this point in the history
Final snapshot
  • Loading branch information
asim42 authored Feb 12, 2018
2 parents 0997cb4 + e9c5572 commit 059ae1a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
20 changes: 8 additions & 12 deletions modules/rds/aurora-db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ resource "aws_rds_cluster" "aurora-cluster" {
db_subnet_group_name = "${aws_db_subnet_group.aurora_subnet_group.name}"
final_snapshot_identifier = "${var.name}-aurora-cluster"
skip_final_snapshot = "${var.skip_final_snapshot}"
vpc_security_group_ids = [
"${
length(var.allowed_security_groups) == 0
? aws_security_group.aurora_db_vpc.id
: aws_security_group.aurora_db_sg.id
}"
vpc_security_group_ids = ["${element(concat(aws_security_group.aurora_db_vpc.*.id, aws_security_group.aurora_db_sg.*.id), 0)}"
]

tags {
Expand Down Expand Up @@ -70,12 +65,13 @@ resource "aws_db_subnet_group" "aurora_subnet_group" {
Environment = "${var.name}"
}
}

resource "aws_security_group" "aurora_db_vpc" {
count = "${length(var.allowed_security_groups) == 0 ? 1 : 0}"

name = "aurora_db-${var.name}"
name = "${var.name}-aurora_db"
vpc_id = "${var.vpc_id}"
description = "Aurora DB security group"
description = "${var.name} Aurora DB security group"

ingress {
protocol = -1
Expand All @@ -92,16 +88,16 @@ resource "aws_security_group" "aurora_db_vpc" {
}

tags {
Name = "aurora_db"
Name = "${var.name}-aurora_db"
}
}

resource "aws_security_group" "aurora_db_sg" {
count = "${length(var.allowed_security_groups) != 0 ? 1 : 0}"

name = "aurora_db-${var.name}"
name = "${var.name}-aurora_db"
vpc_id = "${var.vpc_id}"
description = "Aurora DB security group"
description = "${var.name} Aurora DB security group"

ingress {
protocol = -1
Expand All @@ -118,6 +114,6 @@ resource "aws_security_group" "aurora_db_sg" {
}

tags {
Name = "aurora_db"
Name = "${var.name}-aurora-db"
}
}
8 changes: 2 additions & 6 deletions modules/rds/aurora-db/ouput.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ output "endpoint" {
}

# To allow user to add custom rules to the security group
output "security-group-id"{
value = "${
length(var.allowed_security_groups) == 0
? aws_security_group.aurora_db_vpc.id
: aws_security_group.aurora_db_sg.id
}"
output "security-group-id" {
value = "${element(concat(aws_security_group.aurora_db_vpc.*.id, aws_security_group.aurora_db_sg.*.id), 0)}"
}
4 changes: 2 additions & 2 deletions modules/rds/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ resource "aws_db_instance" "postgresql" {
multi_az = "${var.multi_availability_zone}"
port = "${var.database_port}"
vpc_security_group_ids = ["${element(concat(aws_security_group.postgresql_vpc.*.id, aws_security_group.postgresql_sg.*.id), 0)}"]
db_subnet_group_name = "${var.name}-subnet-group"
parameter_group_name = "${var.name}-parameter-group"
db_subnet_group_name = "${aws_db_subnet_group.postgresql_db_subnet_group.name}"
parameter_group_name = "${aws_db_parameter_group.default.name}"
storage_encrypted = "${var.storage_encrypted}"

tags {
Expand Down
6 changes: 5 additions & 1 deletion modules/rds/postgres/output.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
output "endpoint" {
value = "${aws_db_instance.postgresql.endpoint}"
}
}

output "security-group-id" {
value = "${element(concat(aws_security_group.postgresql_vpc.*.id, aws_security_group.postgresql_sg.*.id), 0)}"
}

0 comments on commit 059ae1a

Please sign in to comment.