From 7ad5c80d0fe7db5091da31b762c28cdd5cbf3c7d Mon Sep 17 00:00:00 2001 From: James Bernardi Date: Wed, 17 Apr 2024 16:17:20 -0400 Subject: [PATCH 1/4] first swipe at enabling autoscaling --- cluster/rds_mysql.tf | 6 +++++- cluster/rds_postgresql.tf | 4 ++++ cluster/variables.tf | 20 ++++++++++++-------- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cluster/rds_mysql.tf b/cluster/rds_mysql.tf index 157fc7f..5c5edc6 100644 --- a/cluster/rds_mysql.tf +++ b/cluster/rds_mysql.tf @@ -2,7 +2,7 @@ module "mysql" { count = var.mysql == null ? 0 : 1 source = "terraform-aws-modules/rds-aurora/aws" - version = "~> 7.6" + version = "~> 9.3" name = "${var.name}-aurora-mysql" engine = "aurora-mysql" @@ -13,6 +13,10 @@ module "mysql" { db_parameter_group_family = var.mysql.db_parameter_family db_parameter_group_parameters = var.mysql.db_parameters + autoscaling_enabled = var.mysql.autoscaling_enabled + autoscaling_min_capacity = var.mysql.autoscaling_min_capacity + autoscaling_max_capacity = var.mysql.replica_count + instances = { for i in range(var.mysql.replica_count) : i => {} diff --git a/cluster/rds_postgresql.tf b/cluster/rds_postgresql.tf index bbfbf3e..edd0fea 100644 --- a/cluster/rds_postgresql.tf +++ b/cluster/rds_postgresql.tf @@ -9,6 +9,10 @@ module "postgresql" { engine_version = var.postgresql.engine_version instance_class = var.postgresql.instance_type + autoscaling_enabled = var.postgresql.autoscaling_enabled + autoscaling_min_capacity = var.postgresql.autoscaling_min_capacity + autoscaling_max_capacity = var.postgresql.replica_count + instances = { for i in range(var.postgresql.replica_count) : i => {} diff --git a/cluster/variables.tf b/cluster/variables.tf index 4084f4a..a38cded 100644 --- a/cluster/variables.tf +++ b/cluster/variables.tf @@ -50,11 +50,13 @@ variable "mysql" { description = "Options controlling the Aurora MySQL cluster" type = object({ - engine_version = string - instance_type = string - replica_count = number - db_parameters = optional(list(map(string)), []) - db_parameter_family = string + engine_version = string + instance_type = string + replica_count = number + db_parameters = optional(list(map(string)), []) + db_parameter_family = string + autoscaling_enabled = optional(bool, false) + autoscaling_min_capacity = optional(number, 0) }) default = null @@ -64,9 +66,11 @@ variable "postgresql" { description = "Options controlling the Aurora PostgreSQL cluster" type = object({ - engine_version = string - instance_type = string - replica_count = number + engine_version = string + instance_type = string + replica_count = number + autoscaling_enabled = optional(bool, false) + autoscaling_min_capacity = optional(number, 0) }) default = null From ee7741798e6123e329995dd0fe58834a6866192b Mon Sep 17 00:00:00 2001 From: James Bernardi Date: Wed, 17 Apr 2024 16:17:33 -0400 Subject: [PATCH 2/4] module version update --- cluster/rds_postgresql.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster/rds_postgresql.tf b/cluster/rds_postgresql.tf index edd0fea..eeb6c91 100644 --- a/cluster/rds_postgresql.tf +++ b/cluster/rds_postgresql.tf @@ -2,7 +2,7 @@ module "postgresql" { count = var.postgresql == null ? 0 : 1 source = "terraform-aws-modules/rds-aurora/aws" - version = "~> 7.6" + version = "~> 9.3" name = "${var.name}-aurora-postgresql" engine = "aurora-postgresql" From f4947f825de267b09b3c13df9d463f7c0c4e9df3 Mon Sep 17 00:00:00 2001 From: James Bernardi Date: Wed, 17 Apr 2024 16:19:39 -0400 Subject: [PATCH 3/4] update docs --- cluster/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cluster/README.md b/cluster/README.md index 3442e4c..7e8802f 100644 --- a/cluster/README.md +++ b/cluster/README.md @@ -23,9 +23,9 @@ | [application](#module\_application) | ./application | n/a | | [ecs](#module\_ecs) | terraform-aws-modules/ecs/aws | ~> 5.7 | | [endpoints](#module\_endpoints) | terraform-aws-modules/vpc/aws//modules/vpc-endpoints | ~> 5.4 | -| [mysql](#module\_mysql) | terraform-aws-modules/rds-aurora/aws | ~> 7.6 | +| [mysql](#module\_mysql) | terraform-aws-modules/rds-aurora/aws | ~> 9.3 | | [nlb\_log\_bucket](#module\_nlb\_log\_bucket) | terraform-aws-modules/s3-bucket/aws | ~> 4.0.1 | -| [postgresql](#module\_postgresql) | terraform-aws-modules/rds-aurora/aws | ~> 7.6 | +| [postgresql](#module\_postgresql) | terraform-aws-modules/rds-aurora/aws | ~> 9.3 | | [s3\_backups](#module\_s3\_backups) | terraform-aws-modules/s3-bucket/aws | ~> 4.0.1 | | [s3\_env](#module\_s3\_env) | terraform-aws-modules/s3-bucket/aws | ~> 4.0.1 | | [s3\_tfstate](#module\_s3\_tfstate) | terraform-aws-modules/s3-bucket/aws | ~> 4.0.1 | @@ -225,9 +225,9 @@ | [backups](#input\_backups) | Options controlling backups behavior |
object({
retention = optional(number, 30)
})
| `{}` | no | | [logs](#input\_logs) | Options controlling CloudWatch and S3 logging behavior |
object({
retention = optional(number, 30)
})
| `{}` | no | | [memcache](#input\_memcache) | Options controlling the Elasticache Memcache cluster |
object({
engine_version = string
node_type = string
num_cache_nodes = number
parameter_group_name = string
})
| `null` | no | -| [mysql](#input\_mysql) | Options controlling the Aurora MySQL cluster |
object({
engine_version = string
instance_type = string
replica_count = number
db_parameters = optional(list(map(string)), [])
db_parameter_family = string
})
| `null` | no | +| [mysql](#input\_mysql) | Options controlling the Aurora MySQL cluster |
object({
engine_version = string
instance_type = string
replica_count = number
db_parameters = optional(list(map(string)), [])
db_parameter_family = string
autoscaling_enabled = optional(bool, false)
autoscaling_min_capacity = optional(number, 0)
})
| `null` | no | | [networking](#input\_networking) | Options controlling networking and security groups |
object({
ingress_ports = optional(list(number), [])
})
| `{}` | no | -| [postgresql](#input\_postgresql) | Options controlling the Aurora PostgreSQL cluster |
object({
engine_version = string
instance_type = string
replica_count = number
})
| `null` | no | +| [postgresql](#input\_postgresql) | Options controlling the Aurora PostgreSQL cluster |
object({
engine_version = string
instance_type = string
replica_count = number
autoscaling_enabled = optional(bool, false)
autoscaling_min_capacity = optional(number, 0)
})
| `null` | no | | [redis](#input\_redis) | Options controlling the Elasticache Redis cluster |
object({
engine_version = string
node_type = string
num_cache_clusters = number
parameter_group = string
})
| `null` | no | | [search](#input\_search) | Options controlling the AWS OpenSearch cluster |
object({
engine_version = string
instance_type = string
instance_count = number
storage_size = number
storage_type = optional(string, "gp2")
storage_iops = optional(number)
storage_throughput = optional(number)
dedicated_node_count = optional(number, 0)
dedicated_node_type = optional(string)
enable_logs = optional(list(string), ["ES_APPLICATION_LOGS"])
})
| `null` | no | | [tags](#input\_tags) | Tags to apply to created resources | `map(string)` | `{}` | no | From 81c3ccc123eca71b62e0f8693cb3c68625d975de Mon Sep 17 00:00:00 2001 From: James Bernardi Date: Thu, 18 Apr 2024 13:30:05 -0400 Subject: [PATCH 4/4] fix outputs --- cluster/outputs.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster/outputs.tf b/cluster/outputs.tf index 9b60c62..50b7c5b 100644 --- a/cluster/outputs.tf +++ b/cluster/outputs.tf @@ -126,10 +126,10 @@ output "efs_security_group_id" { output "mysql_security_group_id" { description = "ID of the security group for the MySQL database" - value = try(module.rds_mysql[0].security_group_id, null) + value = try(module.mysql[0].security_group_id, null) } output "postgresql_security_group_id" { description = "ID of the security group for the PostgreSQL database" - value = try(module.rds_postgresql[0].security_group_id, null) + value = try(module.postgresql[0].security_group_id, null) }