Skip to content

Commit

Permalink
BAH-3902 | Add flag to allow major version upgrade for RDS
Browse files Browse the repository at this point in the history
  • Loading branch information
mohan-13 committed Jun 12, 2024
1 parent 26d4589 commit d1c6cfc
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 39 deletions.
17 changes: 9 additions & 8 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
35 changes: 18 additions & 17 deletions terraform/modules/rds/rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
5 changes: 5 additions & 0 deletions terraform/modules/rds/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
29 changes: 15 additions & 14 deletions terraform/nonprod.tfvars
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

0 comments on commit d1c6cfc

Please sign in to comment.