Skip to content

Commit

Permalink
Add variable to control if major version upgrades are allowed (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-dfds authored Jan 17, 2022
1 parent 328ae55 commit 9875e4f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
17 changes: 9 additions & 8 deletions _sub/database/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions _sub/database/postgres/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions database/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 12 additions & 11 deletions database/postgres/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
6 changes: 6 additions & 0 deletions database/postgres/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 9875e4f

Please sign in to comment.