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

Conversation

owl-king
Copy link
Contributor

@owl-king owl-king commented Aug 2, 2024

Support:

  • multi_az on RDS master node
  • read_replica_2 instance

With enable_rds_main_multiaz = true and create_read_replica_2 = true (default values that works for mainnet, testnet ), this requires changes in state due to index. No new resources are created or deleted. Plan is below

  # aws_db_instance.read_replica_2 has moved to aws_db_instance.read_replica_2[0]
    resource "aws_db_instance" "read_replica_2" {
        id                                    = "dev*-indexer-apne1-db-read-replica-2"
        name                                  = "dydx"
        tags                                  = {
            "Environment" = "dev*"
            "Name"        = "dev*-indexer-apne1-db-read-replica-2"
        }
        # (52 unchanged attributes hidden)
    }

  # aws_route53_record.read_replica_2 has moved to aws_route53_record.read_replica_2[0]
    resource "aws_route53_record" "read_replica_2" {
        id                               = "***"
        name                             = "postgres-main-rr.dydx-indexer.private"
        # (7 unchanged attributes hidden)

        # (1 unchanged block hidden)
    }

With enable_rds_main_multiaz = false and create_read_replica_2 = false, this will delete read_replica_2 instance + route53 records and changes multi_az option. Plan is below

~ resource "aws_db_instance" "main" {
        id                                    = "dev*-indexer-apne1-db"
      ~ multi_az                              = true -> false
        name                                  = "dydx"
        tags                                  = {
            "Environment" = "dev*"
            "Name"        = "dev*-indexer-apne1-db"
        }
        # (63 unchanged attributes hidden)
    }

  # aws_db_instance.read_replica_2[0] will be destroyed
  # (because index [0] is out of range for count)
  # (moved from aws_db_instance.read_replica_2)
  - resource "aws_db_instance" "read_replica_2" {
   .......
   }

- multi_az on RDS master node
- read_replica_2 instance
Comment on lines +476 to +486
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
}
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

@owl-king
Copy link
Contributor Author

owl-king commented Aug 7, 2024

Close the PR as the workflow changes to optimize-aws-cost branch

@owl-king owl-king closed this Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants