Skip to content

Commit

Permalink
Allow to enable/disable:
Browse files Browse the repository at this point in the history
- multi_az on RDS master node
- read_replica_2 instance
  • Loading branch information
owl-king committed Aug 2, 2024
1 parent 73900a0 commit e948588
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion indexer/rds.tf
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ resource "aws_db_instance" "main" {
performance_insights_enabled = true
performance_insights_retention_period = 31
auto_minor_version_upgrade = false
multi_az = true
multi_az = var.enable_rds_main_multiaz

tags = {
Name = local.aws_db_instance_main_name
Expand Down Expand Up @@ -250,6 +250,7 @@ resource "aws_db_instance" "read_replica" {

# Read replica 2
resource "aws_db_instance" "read_replica_2" {
count = var.create_read_replica_2 ? 1 : 0
identifier = "${local.aws_db_instance_main_name}-read-replica-2"
instance_class = var.rds_db_instance_class
# engine, engine_version, name, username, db_subnet_group_name, allocated_storage do not have to
Expand Down
3 changes: 2 additions & 1 deletion indexer/route53.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ resource "aws_route53_record" "read_replica_1" {
}

resource "aws_route53_record" "read_replica_2" {
count = var.create_read_replica_2 ? 1 : 0
zone_id = aws_route53_zone.main.zone_id
name = "postgres-main-rr.dydx-indexer.private"
type = "CNAME"
ttl = "30"
records = ["${aws_db_instance.read_replica_2.address}"]
records = ["${aws_db_instance.read_replica_2[count.index].address}"]
weighted_routing_policy {
weight = 1
}
Expand Down
12 changes: 12 additions & 0 deletions indexer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,15 @@ variable "image_count" {
description = "Number of images to store for ECR, defaults to 100."
default = 100
}

variable "create_read_replica_2" {
description = "Create read replia 2 or not. Default: true"
type = bool
default = true
}

variable "enable_rds_main_multiaz" {
description = "Enable RDS main instance. Default: true"
type = bool
default = true
}

0 comments on commit e948588

Please sign in to comment.