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

Wrong replica initialization #190

Closed
fdmota opened this issue Feb 15, 2021 · 2 comments · Fixed by #243
Closed

Wrong replica initialization #190

fdmota opened this issue Feb 15, 2021 · 2 comments · Fixed by #243

Comments

@fdmota
Copy link

fdmota commented Feb 15, 2021

Hopefully I will be able to describe the problem correctly.

With a configuration like this
engine = "aurora-mysql" replica_scale_enabled = true replica_scale_max = 2 replica_scale_min = 1
I would expect to get 1 writer instance + 1 reader instance. Instead I only get 1 writer.

If I increase replica_scale_min to 2 replica_scale_min = 1, I get 1 writer + 2 readers.
With the current module, It is not possible to initialize the cluster with 1 writer and 1 reader.

I believe the solution leave here
resource "aws_rds_cluster_instance" "this" { count = var.create_cluster ? (var.replica_scale_enabled ? var.replica_scale_min : var.replica_count) : 0

instead it should be
resource "aws_rds_cluster_instance" "this" { count = var.create_cluster ? (var.replica_scale_enabled ? var.replica_scale_min + 1: var.replica_count) : 0

note, this important to have the cluster initialized with at least 1 reader otherwise the application autoscaler won't work, since it needs at least 1 reader to be present.

@emillbrandt
Copy link

The root of the problem is how the replica_scale_min and replica_count are used to create instances and set the autoscaling policy. aws_rds_cluster_instance uses either of those variables to set the total number of instances (writer + readers) but now aws_appautoscaling_target is setting the number of reader instances to one more than desired. The variable names should be changed to reflect that you are setting the number of readers and then your suggested change makes more sense.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants