Skip to content

misleading documentation of google_sql_database_instance data_cache_config behavior in Enterprise Plus Edition #22427

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

Open
nizmitz opened this issue Apr 19, 2025 · 1 comment · May be fixed by GoogleCloudPlatform/magic-modules#13728

Comments

@nizmitz
Copy link

nizmitz commented Apr 19, 2025

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.10.5
on darwin_arm64

  • provider registry.terraform.io/hashicorp/google v6.30.0
  • provider registry.terraform.io/hashicorp/google-beta v6.30.0

Affected Resource(s)

google_sql_database_instance

Terraform Configuration

provider "google" {
  project     = "agnes-learning-project-3"
  region      = "asia-southeast2"
}

provider "google-beta" {
  project     = "agnes-learning-project-3"
  region      = "asia-southeast2"
  zone   = "asia-southeast2-a"
}


resource "google_sql_database_instance" "cache_enabled_ent_plus" {
  name             = "cache-enabled-ent-plus"
  database_version = "POSTGRES_17"
  region           = "asia-southeast2"

  settings {
    tier    = "db-perf-optimized-N-2"
    edition = "ENTERPRISE_PLUS"
    data_cache_config {
        data_cache_enabled = true
    }
  }
}

resource "google_sql_database_instance" "cache_disabled_ent_plus" {
  name             = "cache-disabled-ent-plus"
  database_version = "POSTGRES_17"
  region           = "asia-southeast2"

  settings {
    tier    = "db-perf-optimized-N-2"
    edition = "ENTERPRISE_PLUS"
  }
}

resource "google_sql_database_instance" "cache_disabled_ent" {
  name             = "cache-disabled-ent"
  database_version = "POSTGRES_17"
  region           = "asia-southeast2"

  settings {
    tier = "db-f1-micro"
    edition = "ENTERPRISE"
  }
}

output "cache_enabled_ent_plus" {
  value = {
    edition = google_sql_database_instance.cache_enabled_ent_plus.settings.0.edition
    tier = google_sql_database_instance.cache_enabled_ent_plus.settings.0.tier
    data_cache_config = google_sql_database_instance.cache_enabled_ent_plus.settings.0.data_cache_config
   }
}

output "cache_disabled_ent_plus" {
  value = {
    edition = google_sql_database_instance.cache_disabled_ent_plus.settings.0.edition
    tier = google_sql_database_instance.cache_disabled_ent_plus.settings.0.tier
    data_cache_config = google_sql_database_instance.cache_disabled_ent_plus.settings.0.data_cache_config
   }
}

output "cache_disabled_ent" {
  value = {
    edition = google_sql_database_instance.cache_disabled_ent.settings.0.edition
    tier = google_sql_database_instance.cache_disabled_ent.settings.0.tier
    data_cache_config = google_sql_database_instance.cache_disabled_ent.settings.0.data_cache_config
   }
}

Debug Output

No response

Expected Behavior

CloudSQL data_cache should have defaulted to false as per the documentation in the terraform docs
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/sql_database_instance#data_cache_enabled-1
and also per google documentation it is a optional feature
https://cloud.google.com/sql/docs/mysql/data-cache

when we create CloudSQL with ENTERPISE_PLUS edition if we wanted the data_cache_config to be false we don't need to fill in the argument

Actual Behavior

when we create the CloudSQL with ENTERPISE_PLUS edition the data_cache_config will default to true

Steps to reproduce

  1. terraform apply

Important Factoids

No response

References

After opening a ticket with google it seems the documentation is not yet updated and this behavior was due to this PR
#20393

b/413001944

@melinath
Copy link
Collaborator

melinath commented Apr 23, 2025

It looks like data_cache_config defaults to whatever is returned from the API if it's not provided (which does seem to include data_cache_enabled = true based on our nightly tests.) However, data_cache_enabled itself defaults to false.

I double-checked, and if you set data_cache_config {} (an empty block, which will prevent defaulting to the API's default config) data_cache_enabled will correctly default to false.

This is definitely confusing for users. I'm not entirely clear on what the full API behavior is, so I'm not sure what the best way to fix it on the client side would be.

Relevant documentation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants