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 a team, ayushmjain, imrannayer and q2w 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
@yasra002 yasra002 deleted the patch-3 branch September 1, 2025 11:51
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