Skip to content

Commit

Permalink
upgraded Aurora DB to Serverless V2
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremycook123 committed Jan 26, 2025
1 parent d827b56 commit 9444e0f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ locals {
stocks_app_architecture = "arch1" #either arch1 or arch2
cluster_name = "${local.name}-eks-${local.environment}"
version = "1.27"
version = "1.31"
instance_types = ["m5.large"]
capacity_type = "ON_DEMAND"
disk_size = 10
disk_size = 20
min_size = 2
max_size = 2
desired_size = 2
Expand Down Expand Up @@ -87,9 +87,9 @@ Source Code and Artifacts:

#### Stocks DB

Aurora RDS DB (serverless v1) SQL database:
Aurora RDS DB (serverless v2) SQL database:

- MySQL 5.7
- MySQL 8.0

### Prerequisites
Ensure that the following tools are installed and configured appropriately.
Expand Down
22 changes: 15 additions & 7 deletions terraform/modules/aurora/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resource "aws_security_group" "allow_mysql_from_private_subnets" {
resource "aws_rds_cluster" "cloudacademy" {
cluster_identifier = "cloudacademy"
engine = "aurora-mysql"
engine_mode = "serverless"
engine_version = "8.0.mysql_aurora.3.08.0"
enable_http_endpoint = true

master_username = var.master_username
Expand All @@ -34,18 +34,26 @@ resource "aws_rds_cluster" "cloudacademy" {
db_subnet_group_name = aws_db_subnet_group.cloudacademy.name
vpc_security_group_ids = [aws_security_group.allow_mysql_from_private_subnets.id]

scaling_configuration {
auto_pause = true
min_capacity = 1
max_capacity = 1
seconds_until_auto_pause = 300
timeout_action = "ForceApplyCapacityChange"
serverlessv2_scaling_configuration {
min_capacity = 0.5 # Min ACU
max_capacity = 1.0 # Max ACU
}
}

resource "aws_rds_cluster_instance" "cloudacademy" {
cluster_identifier = aws_rds_cluster.cloudacademy.id
instance_class = "db.serverless"
engine = aws_rds_cluster.cloudacademy.engine
engine_version = aws_rds_cluster.cloudacademy.engine_version
}

#====================================

resource "terraform_data" "db_setup" {
depends_on = [
aws_rds_cluster_instance.cloudacademy
]

triggers_replace = [
filesha1("${path.module}/db_setup.sql")
]
Expand Down

0 comments on commit 9444e0f

Please sign in to comment.