Skip to content

Commit

Permalink
feat: Variablize deletion_protection for aurora-postgres module (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
alldoami authored May 13, 2022
1 parent f03facd commit 6aea3cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 3 additions & 5 deletions aws-aurora-postgres/main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
locals {
# For Aurora postgres, the parameter group names before Postgres version 10
# are named like "aurora-postgresql9.6", but for version 10 and above the
# name omits the minor version e.g. "aurora-postgresql10". We parse the
# engine version to distinguish the 2 cases.
# For version 10 and above the name omits the minor version e.g. "aurora-postgresql10".
split_engine_version = split(".", var.engine_version)
params_engine_version = local.split_engine_version[0] == "9" ? join(".", slice(local.split_engine_version, 0, 2)) : local.split_engine_version[0]
params_engine_version = local.split_engine_version[0]
}

module "aurora" {
Expand All @@ -22,6 +19,7 @@ module "aurora" {
database_subnet_group = var.database_subnet_group
database_password = var.database_password
database_username = var.database_username
db_deletion_protection = var.db_deletion_protection
db_parameters = var.db_parameters
rds_cluster_parameters = var.rds_cluster_parameters
iam_database_authentication_enabled = var.iam_database_authentication_enabled
Expand Down
2 changes: 1 addition & 1 deletion aws-aurora-postgres/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAWSAuroraPostgresInit(t *testing.T) {
}

func TestAWSAuroraPostgresDefaults(t *testing.T) {
versions := []string{"9.6", "10.12", "11.7"}
versions := []string{"10.14", "11.15"}

for _, version := range versions {
v := version
Expand Down
5 changes: 5 additions & 0 deletions aws-aurora-postgres/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,8 @@ variable "auto_minor_version_upgrade" {
description = "Set the databases to automatically upgrade minor versions. WARNING - if this is enabled, make sure engine_version is set to a *prefix* rather that a specific version so that TF won't try to downgrade DB's that have been auto-upgraded. Docs: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_instance#engine_version"
default = false
}

variable "db_deletion_protection" {
type = string
default = false
}

0 comments on commit 6aea3cb

Please sign in to comment.