Skip to content

Commit

Permalink
RDS is still publicly accessible by default, but this can be changed …
Browse files Browse the repository at this point in the history
…now (#1159)

* RDS is still publicly accessible by default, but this can be changed now

* RDS is still publicly accessible by default, but this can be changed now
  • Loading branch information
avnes authored Oct 3, 2023
1 parent d235b11 commit 9d3ba45
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion _sub/database/postgres-restore/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_db_parameter_group" "dbparams" {
resource "aws_db_instance" "postgres" {
engine = "postgres"
engine_version = var.engine_version
publicly_accessible = "true"
publicly_accessible = var.publicly_accessible
deletion_protection = var.deletion_protection
backup_retention_period = 10
apply_immediately = true
Expand Down
6 changes: 6 additions & 0 deletions _sub/database/postgres-restore/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ variable "engine_version" {
description = "RDS engine version (expects major version)"
default = 14
}

variable "publicly_accessible" {
type = bool
default = true
description = "Should the database be public accessible?"
}
6 changes: 3 additions & 3 deletions _sub/database/postgres/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
engine_family = var.engine_version == null ? "postgres13" : "postgres${substr(var.engine_version, 0, 2)}"
engine_family = var.engine_version == null ? "postgres13" : "postgres${substr(var.engine_version, 0, 2)}"
rds_instance_tags = merge({ environment = var.environment }, var.rds_instance_tags, var.tags)
tags = merge({ environment = var.environment }, var.tags)
tags = merge({ environment = var.environment }, var.tags)
}

#tfsec:ignore:no-public-ingress-sgr tfsec:ignore:aws-vpc-no-public-ingress-sg
Expand Down Expand Up @@ -47,7 +47,7 @@ resource "aws_db_parameter_group" "dbparams" {
resource "aws_db_instance" "postgres" {
engine = "postgres"
engine_version = var.engine_version
publicly_accessible = "true"
publicly_accessible = var.publicly_accessible
backup_retention_period = var.db_backup_retention_period
apply_immediately = true
deletion_protection = var.deletion_protection
Expand Down
14 changes: 10 additions & 4 deletions _sub/database/postgres/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,19 @@ variable "db_backup_retention_period" {
}

variable "rds_instance_tags" {
type = map(string)
type = map(string)
description = "A map of tags to apply only to the to RDS instance"
default = {}
default = {}
}

variable "tags" {
type = map(string)
type = map(string)
description = "A map of tags to apply to all the resources deployed by the module"
default = {}
default = {}
}

variable "publicly_accessible" {
type = bool
default = true
description = "Should the database be public accessible?"
}
1 change: 1 addition & 0 deletions database/postgres-restore/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "postgres_restore" {
db_master_password = var.db_master_password
skip_final_snapshot = var.skip_final_snapshot
ssl_mode = var.ssl_mode
publicly_accessible = var.db_publicly_accessible
}

module "param_store_pghost" {
Expand Down
6 changes: 6 additions & 0 deletions database/postgres-restore/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ variable "ssl_mode" {
error_message = "Invalid value for SSL mode. Valid values: Require, VerifyFull, VerifyCA."
}
}

variable "db_publicly_accessible" {
type = bool
default = true
description = "Should the database be public accessible?"
}
1 change: 1 addition & 0 deletions database/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "postgres" {
allow_major_version_upgrade = var.allow_major_version_upgrade
ssl_mode = var.ssl_mode
db_backup_retention_period = var.db_backup_retention_period
publicly_accessible = var.db_publicly_accessible
rds_instance_tags = var.rds_instance_tags
tags = var.tags
}
Expand Down
14 changes: 10 additions & 4 deletions database/postgres/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ variable "db_backup_retention_period" {
}

variable "rds_instance_tags" {
type = map(string)
type = map(string)
description = "A map of tags to apply only to the to RDS instance"
default = {}
default = {}
}

variable "tags" {
type = map(string)
type = map(string)
description = "A map of tags to apply to all the resources deployed by the module"
default = {}
default = {}
}

variable "db_publicly_accessible" {
type = bool
default = true
description = "Should the database be public accessible?"
}

0 comments on commit 9d3ba45

Please sign in to comment.