Skip to content
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

Once Query Insights is enabled, it cannot be disabled afterwards #634

Open
z63d opened this issue Aug 26, 2024 · 1 comment
Open

Once Query Insights is enabled, it cannot be disabled afterwards #634

z63d opened this issue Aug 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@z63d
Copy link

z63d commented Aug 26, 2024

TL;DR

  1. Set insights_config

    module "sql_db" {
      source  = "GoogleCloudPlatform/sql-db/google//modules/mysql"
      version = "21.0.0"
    
      insights_config = {
        query_plans_per_minute  = 0
        query_string_length     = 1024
        record_application_tags = false
        record_client_address   = false
      }
    }
    

    Execute terraform apply.
    Query Insights has been enabled.

  2. Set null in insights_config

    module "sql_db" {
      source  = "GoogleCloudPlatform/sql-db/google//modules/mysql"
      version = "21.0.0"
    
      insights_config = null
    }
    

    Execute terraform plan.

    No changes. Your infrastructure matches the configuration.
    
    Terraform has compared your real infrastructure against your configuration and found no differences, so no changes
    are needed.
    
    Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
    

    Expected behavior is that Query Insights will be disabled.


Probably needs to be changed so that query_insights_enabled = false can be set in the module.

dynamic "insights_config" {

I tried and was able to disable it this way.

like this

resource "google_sql_database_instance" "default" {
  settings {
    insights_config {
      query_insights_enabled = false
    }
  }
}

Are my considerations correct?
If corrections are needed I will create a PR.

Expected behavior

No response

Observed behavior

No response

Terraform Configuration

module "sql_db" {
  source  = "GoogleCloudPlatform/sql-db/google//modules/postgresql"
  version = "21.0.0"

  count = local.postgresql_cloudsql_count

  project_id            = var.project_id
  region                = var.region
  name                  = "postgresql-primary"
  database_version      = "POSTGRES_15"
  edition               = lookup(var.postgresql_cloudsql_module, "edition", null)
  availability_type     = lookup(var.postgresql_cloudsql_module, "availability_type", null)
  tier                  = lookup(var.postgresql_cloudsql_module, "tier", null)
  disk_type             = lookup(var.postgresql_cloudsql_module, "disk_type", null)
  disk_size             = lookup(var.postgresql_cloudsql_module, "disk_size", null)
  disk_autoresize       = lookup(var.postgresql_cloudsql_module, "disk_autoresize", null)
  disk_autoresize_limit = lookup(var.postgresql_cloudsql_module, "disk_autoresize_limit", null)
  zone                  = lookup(var.postgresql_cloudsql_module, "zone", null)
  secondary_zone        = lookup(var.postgresql_cloudsql_module, "secondary_zone", null)
  ip_configuration = {
    private_network    = google_compute_network.main.self_link
    allocated_ip_range = google_service_networking_connection.private_vpc_connection.reserved_peering_ranges[0]
    ipv4_enabled       = false
  }
  insights_config = null
  maintenance_window_day            = lookup(var.postgresql_cloudsql_module, "maintenance_window_day", null)
  maintenance_window_hour           = lookup(var.postgresql_cloudsql_module, "maintenance_window_hour", null)
  maintenance_window_update_track   = lookup(var.postgresql_cloudsql_module, "maintenance_window_update_track", null)
  deny_maintenance_period           = lookup(var.postgresql_cloudsql_module, "deny_maintenance_period", [])
  backup_configuration              = lookup(var.postgresql_cloudsql_module, "backup_configuration", {})
  database_flags                    = lookup(var.postgresql_cloudsql_module, "database_flags", [])
  password_validation_policy_config = lookup(var.postgresql_cloudsql_module, "password_validation_policy_config", {})
  deletion_protection               = lookup(var.postgresql_cloudsql_module, "deletion_protection", null)
  deletion_protection_enabled       = lookup(var.postgresql_cloudsql_module, "deletion_protection_enabled", null)

  enable_default_db = false

  enable_default_user            = true
  user_name                      = "example"
  enable_random_password_special = lookup(var.postgresql_cloudsql_module, "enable_random_password_special", null)
  user_deletion_policy           = lookup(var.postgresql_cloudsql_module, "user_deletion_policy", null)
}

Terraform Version

Terraform v1.9.5
on darwin_arm64
+ provider registry.terraform.io/hashicorp/google v5.40.0
+ provider registry.terraform.io/hashicorp/google-beta v5.42.0
+ provider registry.terraform.io/hashicorp/null v3.2.2
+ provider registry.terraform.io/hashicorp/random v3.6.2

Additional information

No response

@z63d z63d added the bug Something isn't working label Aug 26, 2024
Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants