diff --git a/_sub/database/postgres/main.tf b/_sub/database/postgres/main.tf index 965354fba..05f1aa9e9 100644 --- a/_sub/database/postgres/main.tf +++ b/_sub/database/postgres/main.tf @@ -61,14 +61,15 @@ resource "aws_db_instance" "postgres" { final_snapshot_identifier = "${var.application}-postgres-final-${var.environment}" # configurable - storage_type = var.db_storage_type - instance_class = var.db_instance_class - allocated_storage = var.db_allocated_storage - port = var.db_port - name = var.db_name - username = var.db_master_username - password = var.db_master_password - skip_final_snapshot = var.skip_final_snapshot + storage_type = var.db_storage_type + instance_class = var.db_instance_class + allocated_storage = var.db_allocated_storage + port = var.db_port + name = var.db_name + username = var.db_master_username + password = var.db_master_password + skip_final_snapshot = var.skip_final_snapshot + allow_major_version_upgrade = var.allow_major_version_upgrade timeouts { create = "2h" diff --git a/_sub/database/postgres/vars.tf b/_sub/database/postgres/vars.tf index c57bc9afd..7d3e077a3 100644 --- a/_sub/database/postgres/vars.tf +++ b/_sub/database/postgres/vars.tf @@ -49,3 +49,9 @@ variable "engine_version" { description = "RDS engine version (expects major version)" default = null } + +variable "allow_major_version_upgrade" { + type = bool + description = "Define if major version upgrades to the Postgres engine are allowed" + default = true +} diff --git a/database/postgres/README.md b/database/postgres/README.md index cb467673f..3004f7e2c 100644 --- a/database/postgres/README.md +++ b/database/postgres/README.md @@ -15,3 +15,4 @@ The connection strings, passwords etc can be found in parameter store in the sam - engine_version = 10 (Must be major version. Cannot be downgraded. Optional, but defaults to 10) - db_instance_class - "db.t3.nano" RDS (database instance class. Optional, but defaults to "db.t2.micro") - db_allocated_storage - 10 (The amount of space, in GB, to allocate for the database. Optional, but defaults to 20) +- allow_major_version_upgrade = true (Define if major version upgrades to the Postgres engine are allowed. Optional, but defaults to true) \ No newline at end of file diff --git a/database/postgres/main.tf b/database/postgres/main.tf index 69c0d5d52..16e643613 100644 --- a/database/postgres/main.tf +++ b/database/postgres/main.tf @@ -15,17 +15,18 @@ provider "aws" { # -------------------------------------------------- module "postgres" { - source = "../../_sub/database/postgres" - application = var.application - environment = var.environment - db_name = var.db_name - db_master_username = var.db_master_username - db_master_password = var.db_master_password - db_port = var.db_port - skip_final_snapshot = var.skip_final_snapshot - engine_version = var.engine_version - db_instance_class = var.db_instance_class - db_allocated_storage = var.db_allocated_storage + source = "../../_sub/database/postgres" + application = var.application + environment = var.environment + db_name = var.db_name + db_master_username = var.db_master_username + db_master_password = var.db_master_password + db_port = var.db_port + skip_final_snapshot = var.skip_final_snapshot + engine_version = var.engine_version + db_instance_class = var.db_instance_class + db_allocated_storage = var.db_allocated_storage + allow_major_version_upgrade = var.allow_major_version_upgrade } module "param_store_pghost" { diff --git a/database/postgres/vars.tf b/database/postgres/vars.tf index 3528236c9..96b6dea3b 100644 --- a/database/postgres/vars.tf +++ b/database/postgres/vars.tf @@ -49,3 +49,9 @@ variable "db_allocated_storage" { description = "The amount of space, in GB, to allocate for the database" default = 20 } + +variable "allow_major_version_upgrade" { + type = bool + description = "Define if major version upgrades to the Postgres engine are allowed" + default = true +}