terraform-google-modules / terraform-google-sql-db

Creates a Cloud SQL database instance
https://registry.terraform.io/modules/terraform-google-modules/sql-db/google
Apache License 2.0
265 stars 427 forks source link

fix: Relax assignment of backup_configuration when operating as a replica #589

Closed OscarVanL closed 6 months ago

OscarVanL commented 6 months ago

Relates to issue https://github.com/terraform-google-modules/terraform-google-sql-db/issues/590

In https://github.com/terraform-google-modules/terraform-google-sql-db/pull/556 and https://github.com/terraform-google-modules/terraform-google-sql-db/pull/559 I added the ability to configure the master_instance_name and instance_type on the main google_sql_database_instance created by this module.

The intent was to allow the module to be used for on-premises database migrations, where the primary instance would start as a replica and then later be promoted to the source.

During this change I disabled the assignment of backup_configuration because the docs say:

Backups cannot be enabled on replica instances, but binary logging can be enabled on a replica even when backups are disabled, unlike the primary.

When an instance is configured with a master_instance_name, the instance is operating as a replica, so cannot have backups enabled. This was why I restricted configuring these values.

However, I was overzealous about which configuration items I blocked. For example, binary logging can be enabled on replicas without enabling backups (infact, it must be to enable to create replicas). The only config here I should have restricted is the enabled option, which this PR changes.

imrannayer commented 6 months ago

/gcbrun

OscarVanL commented 6 months ago

Hi @imrannayer, did that come back clear?

imrannayer commented 6 months ago

/gcbrun

imrannayer commented 6 months ago

/gcbrun