Skip to content

Conversation

yasra002
Copy link
Contributor

@yasra002 yasra002 commented Aug 12, 2025

Fixes potential null reference errors when var.zone is not specified by using the local.zone fallback that defaults to first available zone.

fixes: #761

╷
│ Error: Invalid function argument
│ 
│   on .terraform/modules/pg.this.cloud_psql/modules/postgresql/read_replica.tf line 40, in resource "google_sql_database_instance" "replicas":
│   40:   encryption_key_name  = (join("-", slice(split("-", lookup(each.value, "zone", var.zone)), 0, 2))) == var.region ? null : each.value.encryption_key_name
│     ├────────────────
│     │ while calling split(separator, str)
│     │ each.value is object with 16 attributes
│     │ var.zone is null
│ 
│ Invalid value for "str" parameter: argument must not be null.
╵

Fixes potential null reference errors when var.zone is not specified
by using the local.zone fallback that defaults to first available zone.
@yasra002 yasra002 requested review from ayushmjain, imrannayer, q2w and a team as code owners August 12, 2025 08:27
@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer imrannayer merged commit 4eb9309 into terraform-google-modules:main Aug 15, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostgreSQL read replica fails when var.zone is null due to inconsistent zone fallback usage
2 participants