Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to enable/disable multi_az option on master node and remove read_replica_2 instance on dev* #109

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +476 to +486
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would there be a case where the values of these will be different? for example,

create_read_replica_2 = true, enable_rds_main_multiaz = false?

if these two values will stay the same, then would it make sense to combine them into a single variable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It could be possible to be different. For example, if on dev, you want to test the load distribution between read replicas then you should let create_read_replica_2 = true. enable_rds_main_multiaz should be false on dev because that's wasted

Loading