From 5feba103e70a984025f3f9469a5e20022c6fea37 Mon Sep 17 00:00:00 2001 From: harshit410 Date: Tue, 10 Dec 2024 13:56:09 +0530 Subject: [PATCH 1/2] trying to reduce postgres setup time --- main.tf | 2 ++ modules/database/main.tf | 4 ++-- modules/database/variables.tf | 10 ++++++++++ variables.tf | 12 ++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 5f1d1df8..e0484860 100644 --- a/main.tf +++ b/main.tf @@ -111,6 +111,8 @@ module "database" { network_subnets_private = local.network_private_subnets tfe_instance_sg = module.vm.tfe_instance_sg kms_key_arn = local.kms_key_arn + allow_major_version_upgrade = var.allow_major_version_upgrade + allow_multiple_azs = var.allow_multiple_azs } # ----------------------------------------------------------------------------- diff --git a/modules/database/main.tf b/modules/database/main.tf index 5abb1a30..84ca0292 100644 --- a/modules/database/main.tf +++ b/modules/database/main.tf @@ -62,7 +62,7 @@ resource "aws_db_instance" "postgresql" { # no special characters allowed username = var.db_username - allow_major_version_upgrade = false + allow_major_version_upgrade = var.allow_major_version_upgrade apply_immediately = true auto_minor_version_upgrade = true backup_retention_period = var.db_backup_retention @@ -73,7 +73,7 @@ resource "aws_db_instance" "postgresql" { engine_version = var.engine_version identifier_prefix = "${var.friendly_name_prefix}-tfe" max_allocated_storage = 0 - multi_az = true + multi_az = var.allow_multiple_azs # no special characters allowed db_name = var.db_name port = 5432 diff --git a/modules/database/variables.tf b/modules/database/variables.tf index 27b696ed..6a8918ac 100644 --- a/modules/database/variables.tf +++ b/modules/database/variables.tf @@ -65,3 +65,13 @@ variable "kms_key_arn" { description = "The Amazon Resource Name of the KMS key which will be used by the Redis Elasticache replication group to encrypt data at rest." type = string } + +variable "allow_major_version_upgrade" { + type = bool + description = "Determine whether postgres major version upgrade is required or not." +} + +variable "allow_multiple_azs" { + type = bool + description = "Determine Amazon RDS Postgres deployment strategy." +} diff --git a/variables.tf b/variables.tf index 00d7e299..17c76e21 100644 --- a/variables.tf +++ b/variables.tf @@ -189,6 +189,18 @@ variable "postgres_engine_version" { description = "PostgreSQL version." } +variable "allow_major_version_upgrade" { + type = bool + description = "Determine whether postgres major version upgrade is required or not." + default = false +} + +variable "allow_multiple_azs" { + type = bool + description = "Determine Amazon RDS Postgres deployment strategy." + default = true +} + # Aurora # ------ variable "enable_aurora" { From cadbe6fbad459d6e7e8c3325772a502fa3c1188b Mon Sep 17 00:00:00 2001 From: harshit410 Date: Tue, 10 Dec 2024 18:50:27 +0530 Subject: [PATCH 2/2] adding the default values --- modules/database/variables.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/database/variables.tf b/modules/database/variables.tf index 6a8918ac..5361416e 100644 --- a/modules/database/variables.tf +++ b/modules/database/variables.tf @@ -69,9 +69,11 @@ variable "kms_key_arn" { variable "allow_major_version_upgrade" { type = bool description = "Determine whether postgres major version upgrade is required or not." + default = false } variable "allow_multiple_azs" { type = bool description = "Determine Amazon RDS Postgres deployment strategy." + default = true }