Closed aaronblevy closed 5 months ago
Looks like there's a bug where you can create a read replica off a read replica that I need to fix before merging
I also forgot to add validation on Update(), added those checks and some tests 😄. Mainly, you can't change read_replica_source, or update the service to enable HA.
Allow managing a read replica using Terraform. A read replica is specified as a resource with the attribute
read_replica_source
set.The provider applies some validation steps. The main one is to prevent multiple read replicas for the same service. If a user specifies multiple read replicas with the same source, Terraform will attempt to create these in parallel (unless the user specifies a parallelism of one). To get around this, we use a global read replica lock to synchronize the process of creating a read replica. Before we create the replica, we check if there is an existing read replica for a service. To do this, we fetch all the services the project and check if any of the fork configurations specify the same source. This can be later optimized with service level mutexes. Since that would complicates the logic further, it's omitted in this PR.