Modifying byo-vpc to allow dynamic read replica count as a variable (#26)

- Added support for dynamic input of RDS replicas
This commit is contained in:
Jorge Falcon authored and GitHub committed 2025-04-10 12:32:56 -05:00
1 parent f23200d567
commit effca06ef3
3 files changed
+18 -4

No files matched your search

+14 -4
View File
@@ -1,3 +1,16 @@
locals {
replica_numbers = [
"one", "two", "three", "four", "five", "six", "seven", "eight",
"nine", "ten", "eleven", "twelve", "thirteen", "fourteen",
"fifteen", "sixteen"
]
rds_replica_instances = {
for index, replica_number in local.replica_numbers :
replica_number => {} if index < var.rds_config.replicas
}
}
module "byo-db" {
source = "./byo-db"
vpc_id = var.vpc_config.vpc_id
@@ -38,10 +51,7 @@ module "rds" {
engine_version = var.rds_config.engine_version
instance_class = var.rds_config.instance_class
instances = {
one = {}
two = {}
}
instances = local.rds_replica_instances
vpc_id = var.vpc_config.vpc_id
subnets = var.rds_config.subnets
+2
View File
@@ -28,6 +28,7 @@ variable "rds_config" {
preferred_maintenance_window = optional(string, "thu:23:00-fri:00:00")
skip_final_snapshot = optional(bool, true)
backup_retention_period = optional(number, 7)
replicas = optional(number, 2)
})
default = {
name = "fleet"
@@ -49,6 +50,7 @@ variable "rds_config" {
preferred_maintenance_window = "thu:23:00-fri:00:00"
skip_final_snapshot = true
backup_retention_period = 7
replicas = 2
}
description = "The config for the terraform-aws-modules/rds-aurora/aws module"
nullable = false
+2
View File
@@ -79,6 +79,7 @@ variable "rds_config" {
cluster_tags = optional(map(string), {})
skip_final_snapshot = optional(bool, true)
backup_retention_period = optional(number, 7)
replicas = optional(number, 2)
})
default = {
name = "fleet"
@@ -99,6 +100,7 @@ variable "rds_config" {
cluster_tags = {}
skip_final_snapshot = true
backup_retention_period = 7
replicas = 2
}
description = "The config for the terraform-aws-modules/rds-aurora/aws module"
nullable = false