GoogleCloudPlatform / terraform-google-alloy-db

Creates an Alloy DB instance
https://registry.terraform.io/modules/GoogleCloudPlatform/alloy-db/google
Apache License 2.0
18 stars 20 forks source link

Database flags in the secondary cluster getting removed by Terraform #97

Open shubhamoli opened 3 months ago

shubhamoli commented 3 months ago

Hi Team,

We're using this module to provision a primary and a secondary AlloyDB cluster. Everything works well but we're facing a weird issue with DB flags in the secondary cluster. These flags are replicated into secondary from the primary but a subsequent Terraform apply is trying to remove them from the secondary cluster. I believe this is expected from the Terraform's side because DB flags were never part of the its state for the secondary cluster.

Here is the plan

// us-west1 is our secondary cluster

# module.alloydb["us-west1"].module.this.google_alloydb_instance.primary will be updated in-place
  ~ resource "google_alloydb_instance" "primary" {
      ~ database_flags        = {
          - "alloydb.enable_pgaudit"     = "on" -> null
          - "alloydb.iam_authentication" = "on" -> null
          - "log_connections"            = "on" -> null
          - "log_disconnections"         = "on" -> null
          - "log_replication_commands"   = "on" -> null
          - "log_statement"              = "all" -> null
          - "log_timezone"               = "CET" -> null
          - "pgaudit.log"                = "ddl,write" -> null
        }
        # (20 unchanged attributes hidden)
        # (3 unchanged blocks hidden)
    }

TF version - Terraform v1.9.0 Module version - ~> 2.0

Are we doing something wrong here? Any help or pointers will be highly appreciated. Thanks in advance.

sophomeric commented 1 month ago

Bueller? Bueller? Anyone?

imrannayer commented 1 month ago

@shubhamoli have u tried adding those flags in your secondary cluster code?

shubhamoli commented 1 month ago

Hi @imrannayer Yes we tried setting those flags in our secondary cluster but then terraform apply failed with something like.

Setting database flags in the secondary cluster is not allowed (It's not the exact error message)

imrannayer commented 1 month ago

@shubhamoli I will investigate

sophomeric commented 1 month ago

@shubhamoli I will investigate

Any findings to share?