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

feat!: Add dynamic block to define secondary subnets #523

Conversation

jullianow
Copy link
Contributor

The current module that manages subnets gives the possibility of creating secondary networks, however in some cases, we simply need to ignore the management of this block.
This is because, for example, when a GKE cluster is created on a subnet that is being managed by Terraform, if that cluster is configured to automatically create secondary networks, this module will attempt to remove these networks.
Therefore, the objective of this change is basically to modify the behavior of the secondary_ip_range block so that it is only defined if the secondary networks were actually defined in code, thus meaning that the block does not exist if the list is empty.

Ref: https://cloud.google.com/kubernetes-engine/docs/concepts/alias-ips#range_management

@jullianow jullianow requested review from imrannayer and a team as code owners November 30, 2023 17:02
Copy link

google-cla bot commented Nov 30, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer
Copy link
Collaborator

@jullianow integration test failing:


TestPrivateServiceConnect 2023-12-05T16:00:30Z command.go:100: Running command terraform with args [apply -input=false -auto-approve -no-color -lock=false]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: Terraform used the selected providers to generate the following execution
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: plan. Resource actions are indicated with the following symbols:
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + create
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: Terraform planned the following actions, but then encountered a problem:
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.google_compute_global_address.private_service_connect will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_compute_global_address" "private_service_connect" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + address            = "10.3.0.5"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + address_type       = "INTERNAL"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + creation_timestamp = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + effective_labels   = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id                 = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + label_fingerprint  = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name               = "global-psconnect-ip"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + network            = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + prefix_length      = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project            = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + purpose            = "PRIVATE_SERVICE_CONNECT"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + self_link          = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + terraform_labels   = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.google_compute_global_forwarding_rule.forwarding_rule_private_service_connect will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_compute_global_forwarding_rule" "forwarding_rule_private_service_connect" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + base_forwarding_rule  = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + effective_labels      = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id                    = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ip_address            = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ip_protocol           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + label_fingerprint     = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name                  = "globalrule"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + network               = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project               = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + psc_connection_id     = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + psc_connection_status = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + self_link             = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + subnetwork            = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + target                = "all-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + terraform_labels      = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.gcr.google_dns_managed_zone.private[0] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_managed_zone" "private" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + creation_time    = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + description      = "Private DNS zone to configure gcr.io"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + dns_name         = "gcr.io."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + effective_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + force_destroy    = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id               = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone_id  = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name             = "dz-gcr"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name_servers     = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project          = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + terraform_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + visibility       = "private"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + private_visibility_config {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + networks {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:               + network_url = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:             }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.gcr.google_dns_record_set.cloud-static-records["*/CNAME"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-gcr"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "*.gcr.io."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "gcr.io.",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "CNAME"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.gcr.google_dns_record_set.cloud-static-records["/A"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-gcr"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "gcr.io."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "10.3.0.5",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "A"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.googleapis.google_dns_managed_zone.private[0] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_managed_zone" "private" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + creation_time    = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + description      = "Private DNS zone to configure private.googleapis.com."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + dns_name         = "googleapis.com."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + effective_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + force_destroy    = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id               = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone_id  = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name             = "dz-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name_servers     = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project          = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + terraform_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + visibility       = "private"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + private_visibility_config {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + networks {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:               + network_url = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:             }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.googleapis.google_dns_record_set.cloud-static-records["*/CNAME"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "*.googleapis.com."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "private.googleapis.com.",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "CNAME"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.googleapis.google_dns_record_set.cloud-static-records["private/A"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "private.googleapis.com."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "10.3.0.5",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "A"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.pkg_dev.google_dns_managed_zone.private[0] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_managed_zone" "private" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + creation_time    = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + description      = "Private DNS zone to configure pkg.dev"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + dns_name         = "pkg.dev."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + effective_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + force_destroy    = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id               = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone_id  = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name             = "dz-pkg-dev"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name_servers     = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project          = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + terraform_labels = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + visibility       = "private"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + private_visibility_config {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + networks {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:               + network_url = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:             }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.pkg_dev.google_dns_record_set.cloud-static-records["*/CNAME"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-pkg-dev"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "*.pkg.dev."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "pkg.dev.",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "CNAME"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.private_service_connect.module.pkg_dev.google_dns_record_set.cloud-static-records["/A"] will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_dns_record_set" "cloud-static-records" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id           = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + managed_zone = "dz-pkg-dev"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name         = "pkg.dev."
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project      = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + rrdatas      = [
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:           + "10.3.0.5",
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:         ]
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + ttl          = 300
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + type         = "A"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   # module.simple_vpc.module.vpc.google_compute_network.network will be created
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + resource "google_compute_network" "network" {
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + auto_create_subnetworks                   = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + delete_default_routes_on_create           = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + enable_ula_internal_ipv6                  = false
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + gateway_ipv4                              = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + id                                        = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + internal_ipv6_range                       = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + mtu                                       = 1460
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + name                                      = "my-custom-network"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + network_firewall_policy_enforcement_order = "AFTER_CLASSIC_FIREWALL"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + project                                   = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + routing_mode                              = "GLOBAL"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:       + self_link                                 = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     }
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: Plan: 12 to add, 0 to change, 0 to destroy.
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: Changes to Outputs:
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + dns_zone_gcr_name            = "dz-gcr"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + dns_zone_googleapis_name     = "dz-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + dns_zone_pkg_dev_name        = "dz-pkg-dev"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + forwarding_rule_name         = "globalrule"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + forwarding_rule_target       = "all-apis"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + global_address_id            = (known after apply)
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + network_name                 = "my-custom-network"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + private_service_connect_ip   = "10.3.0.5"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + private_service_connect_name = "global-psconnect-ip"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   + project_id                   = "ci-network-803d"
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: Error: Unsupported attribute
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   on ../../modules/subnets/main.tf line 56, in resource "google_compute_subnetwork" "subnetwork":
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:   56:     for_each = contains(keys(var.secondary_ranges), each.value.name) == true ? var.secondary_ranges[each.value.name] : []
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     ├────────────────
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185:     │ each.value is object with 16 attributes
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: 
TestPrivateServiceConnect 2023-12-05T16:00:57Z command.go:185: This object does not have an attribute named "name".
TestPrivateServiceConnect 2023-12-05T16:00:57Z retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; 
Error: Unsupported attribute

  on ../../modules/subnets/main.tf line 56, in resource "google_compute_subnetwork" "subnetwork":
  56:     for_each = contains(keys(var.secondary_ranges), each.value.name) == true ? var.secondary_ranges[each.value.name] : []
    ├────────────────
    │ each.value is object with 16 attributes

This object does not have an attribute named "name".}
    apply.go:34: 
        	Error Trace:	/builder/home/go/pkg/mod/github.com/gruntwork-io/[email protected]/modules/terraform/apply.go:34
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:437
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:447
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:471
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/utils/stages.go:31
        	            				/builder/home/go/pkg/mod/github.com/!google!cloud!platform/cloud-foundation-toolkit/infra/[email protected]/pkg/tft/terraform.go:471
        	Error:      	Received unexpected error:
        	            	FatalError{Underlying: error while running command: exit status 1; 
        	            	Error: Unsupported attribute
        	            	
        	            	  on ../../modules/subnets/main.tf line 56, in resource "google_compute_subnetwork" "subnetwork":
        	            	  56:     for_each = contains(keys(var.secondary_ranges), each.value.name) == true ? var.secondary_ranges[each.value.name] : []
        	            	    ├────────────────
        	            	    │ each.value is object with 16 attributes
        	            	
        	            	This object does not have an attribute named "name".}
        	Test:       	TestPrivateServiceConnect
2023/12/05 16:00:57 RUN_STAGE env var set to apply
2023/12/05 16:00:57 Skipping stage teardown

@jullianow
Copy link
Contributor Author

@imrannayer How can I run these tests?

@imrannayer
Copy link
Collaborator

@jullianow check this. For test written in go you can use

cft test list

and

cft test run <test-name>

…t in the secondary_ip_range block

Signed-off-by: Julliano Goncalves <[email protected]>
@jullianow
Copy link
Contributor Author

@imrannayer Adjusted.

[root@f7bdcaf7379c workspace]# cft test run TestSecondaryRanges
ok  	github.com/terraform-google-modules/terraform-google-network/test/integration/secondary_ranges	143.849s

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer
Copy link
Collaborator

/gcbrun

1 similar comment
@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer
Copy link
Collaborator

/gcbrun

@imrannayer imrannayer changed the title feat: Add dynamic block to define secondary subnets feat!: Add dynamic block to define secondary subnets Dec 9, 2023
@imrannayer imrannayer self-requested a review December 9, 2023 21:07
@jullianow
Copy link
Contributor Author

Any updates on this?

@jullianow
Copy link
Contributor Author

Any updates on this?

@apeabody
Copy link
Contributor

/gcbrun

@imrannayer
Copy link
Collaborator

I will merge it and test with older version to see if this cause cause any breaking changes. If so we will revert it.

@imrannayer imrannayer merged commit 2adc566 into terraform-google-modules:master Dec 25, 2023
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.

3 participants