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

Terrform Postgres Module creates MySQL Instance - Clarify documentation #610

Open
KiranK-4 opened this issue Jun 20, 2024 · 4 comments · May be fixed by #665
Open

Terrform Postgres Module creates MySQL Instance - Clarify documentation #610

KiranK-4 opened this issue Jun 20, 2024 · 4 comments · May be fixed by #665
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@KiranK-4
Copy link

TL;DR

Using the Postgres module creates a MySQL Instance using the same values provided in the README.md

Expected behavior

It should create a POSTGRES_9_6 database instance

Observed behavior

It creates MySQL 8.0 version Instance

Terraform Configuration

module "pg" {
  # checkov:skip=CKV_GCP_62:
  # checkov:skip=CKV_TF_1:
  source                          = "terraform-google-modules/sql-db/google//modules/postgresql"
  version                         = "~> 20.1"
  name                            = var.instance_name
  random_instance_name            = true
  project_id                      = var.project_id
  database_version                = var.db_version
  region                          = var.region
  db_name                         = var.db_name
  disk_size                       = var.db_disk_size
  disk_type                       = var.db_disk_type
  db_charset                      = "UTF8"
  db_collation                    = "en_US.UTF8"
  user_name                       = "${var.prefix}_user"
  user_password                   = var.password
  maintenance_window_day          = 7
  maintenance_window_hour         = 12
  maintenance_window_update_track = "stable"

  database_flags = [
    { name = "log_connections", value = "on" },
    { name = "log_min_duration_statement", value = "-1" },
    { name = "log_disconnections", value = "on" },
    { name = "log_lock_waits", value = "on" },

  ]

  ip_configuration = {
    ipv4_enabled       = false
    require_ssl        = false
    private_network    = var.vpc_network
    allocated_ip_range = null
    # authorized_networks = [
    #   {
    #     name  = "${var.project_id}-cidr"
    #     value = var.pg_ha_external_ip_range
    #   },
    # ]
  }

  backup_configuration = {
    enabled                        = true
    start_time                     = "20:55"
    location                       = null
    point_in_time_recovery_enabled = false
    transaction_log_retention_days = null
    retained_backups               = 90
    retention_unit                 = "COUNT"
  }
}

Terraform Version

required_version = ">= 0.13"

Additional information

No response

@KiranK-4 KiranK-4 added the bug Something isn't working label Jun 20, 2024
@imrannayer
Copy link
Collaborator

@KiranK-4 what are the values passed in var.db_version?

@imrannayer imrannayer added the waiting-response Waiting for issue author to respond. label Aug 2, 2024
@alabdao
Copy link

alabdao commented Sep 4, 2024

I see the same issue. I keep getting MYSQL 8.0 created while I have specified POSTGRES_16_3
However, when I just specify 16 as version, I get the correct DB created.
Here's the HCL code:

module "sql" {
  providers = {
    google = google.use1
  }
  source  = "terraform-google-modules/sql-db/google//modules/postgresql"
  version = "~> 21.0"
  name             = "${var.folder}-${var.environment}-${var.region_short_name}-db"
  project_id       = local.project_id
  database_version = "POSTGRES_16_3"
  region           = var.region
}

@imrannayer imrannayer removed the waiting-response Waiting for issue author to respond. label Sep 4, 2024
@imrannayer
Copy link
Collaborator

I think variable description is misleading. It is expecting

9_6, 10, 11, 12, 13, 14, 15, 16 etc

Here is the logic

can(regex("\\d", substr(var.database_version, 0, 1))) ? format("POSTGRES_%s", var.database_version) : replace(var.database_version, substr(var.database_version, 0, 8), "POSTGRES")

@imrannayer imrannayer changed the title Terrform Postgres Module creates MySQL Instance Terrform Postgres Module creates MySQL Instance - Clarify documentation Sep 5, 2024
@imrannayer imrannayer added enhancement New feature or request good first issue Good for newcomers and removed bug Something isn't working labels Sep 5, 2024
Copy link

github-actions bot commented Nov 4, 2024

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

@github-actions github-actions bot added the Stale label Nov 4, 2024
@imrannayer imrannayer removed the Stale label Nov 4, 2024
@imrannayer imrannayer linked a pull request Nov 4, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants