From d1c6cfcd3db0966432042b389bfb7e8619ca919e Mon Sep 17 00:00:00 2001 From: MOHANKUMAR T Date: Wed, 12 Jun 2024 13:32:21 +0530 Subject: [PATCH] BAH-3902 | Add flag to allow major version upgrade for RDS --- terraform/main.tf | 17 ++++++++------- terraform/modules/rds/rds.tf | 35 +++++++++++++++--------------- terraform/modules/rds/variables.tf | 5 +++++ terraform/nonprod.tfvars | 29 +++++++++++++------------ terraform/variables.tf | 6 +++++ 5 files changed, 53 insertions(+), 39 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index 5128418..2a0458a 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -45,14 +45,15 @@ module "eks" { } module "rds" { - source = "./modules/rds" - depends_on = [module.vpc] - environment = var.environment - vpc_suffix = var.vpc_suffix - mysql_rds_port = var.mysql_rds_port - mysql_version = var.mysql_version - rds_instance_class = var.rds_instance_class - mysql_time_zone = var.mysql_time_zone + source = "./modules/rds" + depends_on = [module.vpc] + environment = var.environment + vpc_suffix = var.vpc_suffix + mysql_rds_port = var.mysql_rds_port + mysql_version = var.mysql_version + rds_instance_class = var.rds_instance_class + rds_allow_major_version_upgrade = var.rds_allow_major_version_upgrade + mysql_time_zone = var.mysql_time_zone } module "ses" { diff --git a/terraform/modules/rds/rds.tf b/terraform/modules/rds/rds.tf index 6731e5f..5b7083b 100644 --- a/terraform/modules/rds/rds.tf +++ b/terraform/modules/rds/rds.tf @@ -8,23 +8,24 @@ resource "aws_db_subnet_group" "mysql-subnet" { } resource "aws_db_instance" "mysql" { - identifier = "bahmni-rds-${var.environment}" - allocated_storage = 10 - max_allocated_storage = 30 - skip_final_snapshot = true - engine = "mysql" - engine_version = var.mysql_version - instance_class = var.rds_instance_class - username = random_string.mysql_user_name.result - password = random_string.mysql_user_password.result - vpc_security_group_ids = [aws_security_group.rds.id] - storage_encrypted = true - db_subnet_group_name = aws_db_subnet_group.mysql-subnet.name - publicly_accessible = false - apply_immediately = true - port = var.mysql_rds_port - backup_retention_period = 2 - parameter_group_name = aws_db_parameter_group.custom_mysql_parameters.name + identifier = "bahmni-rds-${var.environment}" + allocated_storage = 10 + max_allocated_storage = 30 + skip_final_snapshot = true + engine = "mysql" + engine_version = var.mysql_version + instance_class = var.rds_instance_class + username = random_string.mysql_user_name.result + password = random_string.mysql_user_password.result + vpc_security_group_ids = [aws_security_group.rds.id] + storage_encrypted = true + db_subnet_group_name = aws_db_subnet_group.mysql-subnet.name + publicly_accessible = false + apply_immediately = true + allow_major_version_upgrade = var.rds_allow_major_version_upgrade + port = var.mysql_rds_port + backup_retention_period = 2 + parameter_group_name = aws_db_parameter_group.custom_mysql_parameters.name } resource "random_string" "mysql_user_name" { diff --git a/terraform/modules/rds/variables.tf b/terraform/modules/rds/variables.tf index fa9b194..48c2002 100644 --- a/terraform/modules/rds/variables.tf +++ b/terraform/modules/rds/variables.tf @@ -27,3 +27,8 @@ variable "mysql_time_zone" { type = string description = "Time Zone for RDS Instance" } + +variable "rds_allow_major_version_upgrade" { + type = bool + description = "Allow Major Version Upgrade for RDS Instance" +} diff --git a/terraform/nonprod.tfvars b/terraform/nonprod.tfvars index b79ad5e..40c672e 100644 --- a/terraform/nonprod.tfvars +++ b/terraform/nonprod.tfvars @@ -1,14 +1,15 @@ -environment = "nonprod" -vpc_suffix = "nonprod" -owner = "bahmni-infra" -availability_zones = ["ap-south-1a", "ap-south-1b"] -private_cidr_blocks = ["10.0.1.0/24", "10.0.2.0/24"] -public_cidr_blocks = ["10.0.3.0/24", "10.0.4.0/24"] -vpc_cidr_block = "10.0.0.0/16" -rds_instance_class = "db.t3.large" -mysql_version = "8.0" -mysql_rds_port = "3306" -mysql_time_zone = "Asia/Calcutta" -enable_bastion_host = false -bastion_public_access_cidr = "0.0.0.0/0" -enable_ses = true +environment = "nonprod" +vpc_suffix = "nonprod" +owner = "bahmni-infra" +availability_zones = ["ap-south-1a", "ap-south-1b"] +private_cidr_blocks = ["10.0.1.0/24", "10.0.2.0/24"] +public_cidr_blocks = ["10.0.3.0/24", "10.0.4.0/24"] +vpc_cidr_block = "10.0.0.0/16" +rds_instance_class = "db.t3.large" +rds_allow_major_version_upgrade = true +mysql_version = "8.0" +mysql_rds_port = "3306" +mysql_time_zone = "Asia/Calcutta" +enable_bastion_host = false +bastion_public_access_cidr = "0.0.0.0/0" +enable_ses = true diff --git a/terraform/variables.tf b/terraform/variables.tf index 1e3a7e9..315d8f7 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -78,3 +78,9 @@ variable "enable_ses" { default = false description = "Toggle for SES Module" } + +variable "rds_allow_major_version_upgrade" { + type = bool + description = "Allow Major Version Upgrade for RDS Instance" + +}