Skip to content
This repository was archived by the owner on Jun 27, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion rds-instance-full/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,29 @@ module "rds_security_group" {
ingress_rules = ["${var.ingress_rule}"]
}

module "custom_security_group" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace ecs in all arguments to this module with something like custom.

Word "custom" is more suitable for this module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All ecs references got removed

source = "terraform-aws-modules/security-group/aws"

create = "${var.custom_sg_id == "" ? 0 : 1 }"

name = "${local.identifier}-rds-custom"
description = "Security group with RDS ports open for a custom security group"
vpc_id = "${data.terraform_remote_state.vpc.vpc_id}"

ingress_cidr_blocks = ["${data.terraform_remote_state.vpc.vpc_cidr_block}"]

ingress_with_source_security_group_id = [
{
rule = "${var.ingress_rule}"
source_security_group_id = "${var.custom_sg_id}"
},
]
}

locals {
security_group_id = "${coalesce(join("", module.custom_security_group.*.security_group_id), module.rds_security_group.this_security_group_id)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, join("", module.custom_security_group.*.security_group_id) can be replaced with module.custom_security_group.security_group_id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it didn't work when I was working on it as addition for the RDS module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@antonbabenko I will test this in RDS Neo module anyway, so I can do new PR removing this if it wouldn't be necessary

}

data "aws_db_snapshot" "manual" {
count = "${var.manual_db_snapshot_identifier == "" ? 0 : 1}"

Expand Down Expand Up @@ -71,7 +94,7 @@ module "rds" {

snapshot_identifier = "${join("", data.aws_db_snapshot.manual.*.db_snapshot_arn)}"

vpc_security_group_ids = ["${module.rds_security_group.this_security_group_id}"]
vpc_security_group_ids = ["${local.security_group_id}"]
maintenance_window = "${var.maintenance_window}"
backup_window = "${var.backup_window}"
backup_retention_period = "${var.backup_retention_period}"
Expand Down
5 changes: 5 additions & 0 deletions rds-instance-full/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ variable "license_model" {
description = "License model information for this DB instance. Optional, but required for some DB engines, i.e. Oracle SE1"
default = ""
}

variable "custom_sg_id" {
description = "Custom security group id which should be allowed to have access to this RDS instance"
default = ""
}