diff --git a/byo-vpc/main.tf b/byo-vpc/main.tf index 694e102..e2d47d5 100644 --- a/byo-vpc/main.tf +++ b/byo-vpc/main.tf @@ -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 diff --git a/byo-vpc/variables.tf b/byo-vpc/variables.tf index aa5913c..031cc4b 100644 --- a/byo-vpc/variables.tf +++ b/byo-vpc/variables.tf @@ -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 diff --git a/variables.tf b/variables.tf index db4bd54..5f04b0b 100644 --- a/variables.tf +++ b/variables.tf @@ -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