gruntwork-io / terraform-google-sql

Terraform modules for deploying Google Cloud SQL (e.g. MySQL, PostgreSQL) in GCP
https://gruntwork.io
Apache License 2.0
92 stars 103 forks source link

MySQL Read replica implementation #19

Closed autero1 closed 5 years ago

autero1 commented 5 years ago

This PR adds support for Cloud SQL read replicas.

Fixes #16

autero1 commented 5 years ago

Yes, the outputs and related documentation are on my final todo list. The certificate outputs are something I don't use in the tests for the replicas, so I didn't finalize them. Wanted to push this out 90% complete to get regression feedback from the tests.

autero1 commented 5 years ago

Until terraform 0.12 certain things are a dead end due to this: https://github.com/hashicorp/terraform/issues/17048

It's what was problematic with the IP addresses and now it's the same condition for server certs for the read replicas. If we're sure the count of a resource is never > 1, we don't have to use the splat operator. This is the case for the failover replica, so we can write:

data "template_file" "failover_certificate" {
  count    = "${var.enable_failover_replica}"
  template = "${google_sql_database_instance.failover_replica.0.server_ca_cert.0.cert}"
}

But now with potentially more than one read replica, we cannot do that. Using splat fails due to the terraform issue. The tests are currently failing because of this issue.

autero1 commented 5 years ago

Until terraform 0.12 certain things are a dead end due to this: hashicorp/terraform#17048

I ended up

I think this is a reasonably ok interim solution before we have terraform 0.12

autero1 commented 5 years ago

No longer WIP