Skip to content

[Bug Report] Static public IP not attached to Panorama instance when public_static_ip is null #83

@p0g4rdy

Description

@p0g4rdy

Describe the bug

Summary

The Panorama module creates a static IP reservation (google_compute_address.public) but fails to attach it to the instance. Instead, the instance receives an ephemeral public IP.

Affected File

modules/panorama/main.tf - line 66 (access_config block)

Root Cause

The try() function is used incorrectly for null-coalescing:

nat_ip = try(var.public_static_ip, google_compute_address.public[0].address)

When var.public_static_ip is null, try() returns null because accessing a null variable doesn't throw an error. The fallback value is never used.

Expected Behavior

When attach_public_ip = true and public_static_ip is not specified, the instance should use the auto-created static IP from google_compute_address.public[0].

Actual Behavior

The instance receives an ephemeral public IP. The reserved static IP exists but remains unassigned.

Fix

Replace try() with a proper null check:

nat_ip = var.public_static_ip != null ? var.public_static_ip : google_compute_address.public[0].address

Steps to Reproduce

  1. Deploy Panorama with attach_public_ip = true and no public_static_ip specified
  2. Check GCP Console → VPC Network → IP addresses
  3. Observe: Static IP is reserved but "In use by" is empty
  4. Check instance network interface: Shows ephemeral IP, not the reserved static IP

Additional Notes

The same pattern with try() appears in other places and may have similar issues:

  • Line 14: address = try(var.private_static_ip, null)
  • Line 25: address = try(var.public_static_ip, null)

These usages are harmless (setting optional attributes to null is valid), but the pattern is misleading.

Module Version

v2.0.11

Terraform version

Terraform v1.14.4

Expected behavior

No response

Current behavior

No response

Anything else to add?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions