hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.29k stars 1.72k forks source link

Correct usage of "service_directory_registrations" block in "google_compute_forwarding_rule" with PSC / Private Service Connect? #17965

Open ppuschmann opened 4 months ago

ppuschmann commented 4 months ago

Question

Hi,

the configuration example for "Forwarding Rule VPC PSC" shows this configuration:

// Forwarding rule for VPC private service connect
resource "google_compute_forwarding_rule" "default" {
  name                    = "psc-endpoint"
  region                  = "us-central1"
  load_balancing_scheme   = ""
  target                  = google_compute_service_attachment.producer_service_attachment.id
  network                 = google_compute_network.consumer_net.name
  ip_address              = google_compute_address.consumer_address.id
  allow_psc_global_access = true
}

which I would extend with the following block to configure the Service Directory namespace and service name:

  service_directory_registrations {
    namespace = "my-psc"
    service   = "my-psc-service"
  }

Given the PSC-Attachment is configure with the attribute domain domain = "dev.psc.example.com.", I'd expect the service to be discoverable as:

my-psc-service.dev.psc.example.com

While provisioning this configuration I get an error message:

// Forwarding rule for VPC private service connect
resource "google_compute_forwarding_rule" "default" {
  name                    = "psc-endpoint"
  region                  = "us-central1"
  load_balancing_scheme   = ""
  target                  = google_compute_service_attachment.producer_service_attachment.id
  network                 = google_compute_network.consumer_net.name
  ip_address              = google_compute_address.consumer_address.id
  allow_psc_global_access = true

  service_directory_registrations {
    namespace = "my-psc"
    service   = "my-psc-service"
  }
}

If I remove the service, I can provision the PSC-Endpoint / Forwarding Rule.

Only that my service then is only discoverable via the hostname producer-service-euw1.dev.psc.example.com.

Where do the single parts come from?

My expectation (with a working service attribute in service_directory_registrations) would have been:

Questions

Provider Version

Terraform provider: google, version 5.26.0

slavayssiere-stacklabs commented 4 weeks ago

Same behaviour on 5.42.0. Any idea to solve this ?