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

Region Variable should be marked required #526

Closed
jruydemir opened this issue Oct 10, 2023 · 2 comments
Closed

Region Variable should be marked required #526

jruydemir opened this issue Oct 10, 2023 · 2 comments
Assignees
Labels
bug Something isn't working Stale

Comments

@jruydemir
Copy link

TL;DR

Got an error of an "unrecognized GCE zone" when attempting to build without the region defined. This was corrected when region was included.

Expected behavior

Given that zone is required and region isn't I didn't include region. Figured there was some code to pull out the region from the zone. So I expected it to build with only the "Required" variables.

Observed behavior

Instead, I got the following terraform error.

module.sql-db_mysql.google_sql_database_instance.default: Creating...
╷
│ Error: Error, failed to create instance inm-platform-orchestration-db: googleapi: Error 400: Request contains unrecognized GCE zone when creating or updating an instance., errorUnrecognizedGceZone
│
│   with module.sql-db_mysql.google_sql_database_instance.default,
│   on .terraform/modules/sql-db_mysql/modules/mysql/main.tf line 43, in resource "google_sql_database_instance" "default":
│   43: resource "google_sql_database_instance" "default" {
│
╵

Terraform Configuration

module "sql-db_mysql" {
  source  = "GoogleCloudPlatform/sql-db/google//modules/mysql"
  version = "16.1.0"

  name             = "${var.project}-db"
  project_id       = var.project
  zone             = "us-east1-c"
  secondary_zone   = "us-east1-d"
  database_version = "MYSQL_5_6"
  tier             = "db-n1-standard-1"

  db_charset                      = "utf8mb4"
  db_collation                    = "utf8mb4_general_ci"
  edition                         = "ENTERPRISE"
  maintenance_window_day          = 3
  maintenance_window_hour         = 20
  maintenance_window_update_track = "stable"

  deletion_protection                      = var.prod
  deletion_protection_enabled              = var.prod
  read_replica_deletion_protection         = var.prod
  read_replica_deletion_protection_enabled = var.prod

  ip_configuration = {
    allocated_ip_range  = null
    authorized_networks = []
    ipv4_enabled        = false
    private_network     = "projects/ex-network/global/networks/mynetwork"
    require_ssl         = true
  }

  backup_configuration = {
    binary_log_enabled             = true
    enabled                        = true
    location                       = "us-east1"
    retained_backups               = 10
    retention_unit                 = "COUNT"
    start_time                     = "00:00"
    transaction_log_retention_days = 5
  }
}


### Terraform Version

```sh
Terraform v1.5.7

Additional information

I tried this on the following versions of this module to the same result.

16.1.0
16.0.0
15.0.0
14.0.0

@jruydemir jruydemir added the bug Something isn't working label Oct 10, 2023
@3sne
Copy link

3sne commented Nov 15, 2023

I tested this on the latest provider version(5.6.0) and got the same result. The region variable has us-central1 set as the default value. If a module config sets only the zone variable, looks like it must be a zone in the default us-central1 region, else the apply will fail with a 400 error.

The simplest solution to avoid this scenario would be to make the region variable required, as suggested by @jruydemir. I guess this will be a breaking change.

In fact, zone can even be made optional as when no zone is passed, the Cloud SQL instance uses a random available zone from the given region automatically.

Copy link

github-actions bot commented Mar 2, 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 Mar 2, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

3 participants