diff --git a/.changelog/3755.txt b/.changelog/3755.txt new file mode 100644 index 00000000000..347dfab8132 --- /dev/null +++ b/.changelog/3755.txt @@ -0,0 +1,3 @@ +```release-note:bug +all: updated base urls for compute, dns, storage, and bigquery APIs to their recommended endpoints +``` diff --git a/google/config.go b/google/config.go index 7135b84303f..88680f15830 100644 --- a/google/config.go +++ b/google/config.go @@ -230,7 +230,7 @@ var AccessApprovalDefaultBasePath = "https://accessapproval.googleapis.com/v1/" var AccessContextManagerDefaultBasePath = "https://accesscontextmanager.googleapis.com/v1/" var ActiveDirectoryDefaultBasePath = "https://managedidentities.googleapis.com/v1/" var AppEngineDefaultBasePath = "https://appengine.googleapis.com/v1/" -var BigQueryDefaultBasePath = "https://www.googleapis.com/bigquery/v2/" +var BigQueryDefaultBasePath = "https://bigquery.googleapis.com/bigquery/v2/" var BigqueryDataTransferDefaultBasePath = "https://bigquerydatatransfer.googleapis.com/v1/" var BigtableDefaultBasePath = "https://bigtableadmin.googleapis.com/v2/" var BinaryAuthorizationDefaultBasePath = "https://binaryauthorization.googleapis.com/v1/" @@ -241,14 +241,14 @@ var CloudIotDefaultBasePath = "https://cloudiot.googleapis.com/v1/" var CloudRunDefaultBasePath = "https://{{location}}-run.googleapis.com/" var CloudSchedulerDefaultBasePath = "https://cloudscheduler.googleapis.com/v1/" var CloudTasksDefaultBasePath = "https://cloudtasks.googleapis.com/v2/" -var ComputeDefaultBasePath = "https://www.googleapis.com/compute/v1/" +var ComputeDefaultBasePath = "https://compute.googleapis.com/compute/v1/" var ContainerAnalysisDefaultBasePath = "https://containeranalysis.googleapis.com/v1/" var DataCatalogDefaultBasePath = "https://datacatalog.googleapis.com/v1/" var DataprocDefaultBasePath = "https://dataproc.googleapis.com/v1/" var DatastoreDefaultBasePath = "https://datastore.googleapis.com/v1/" var DeploymentManagerDefaultBasePath = "https://www.googleapis.com/deploymentmanager/v2/" var DialogflowDefaultBasePath = "https://dialogflow.googleapis.com/v2/" -var DNSDefaultBasePath = "https://www.googleapis.com/dns/v1/" +var DNSDefaultBasePath = "https://dns.googleapis.com/dns/v1/" var FilestoreDefaultBasePath = "https://file.googleapis.com/v1/" var FirestoreDefaultBasePath = "https://firestore.googleapis.com/v1/" var GameServicesDefaultBasePath = "https://gameservices.googleapis.com/v1/" @@ -273,7 +273,7 @@ var ServiceUsageDefaultBasePath = "https://serviceusage.googleapis.com/v1/" var SourceRepoDefaultBasePath = "https://sourcerepo.googleapis.com/v1/" var SpannerDefaultBasePath = "https://spanner.googleapis.com/v1/" var SQLDefaultBasePath = "https://sqladmin.googleapis.com/sql/v1beta4/" -var StorageDefaultBasePath = "https://www.googleapis.com/storage/v1/" +var StorageDefaultBasePath = "https://storage.googleapis.com/storage/v1/" var TPUDefaultBasePath = "https://tpu.googleapis.com/v1/" var VPCAccessDefaultBasePath = "https://vpcaccess.googleapis.com/v1/" diff --git a/google/data_source_google_compute_zones.go b/google/data_source_google_compute_zones.go index 8e40941cf7a..ddf89a3b6f1 100644 --- a/google/data_source_google_compute_zones.go +++ b/google/data_source_google_compute_zones.go @@ -4,6 +4,7 @@ import ( "fmt" "log" "sort" + "strings" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" @@ -51,30 +52,28 @@ func dataSourceGoogleComputeZonesRead(d *schema.ResourceData, meta interface{}) return err } - // we want to share exactly the same base path as the compute client or the - // region string may mismatch, giving us no results - // note that the client's BasePath includes a `projects/` suffix, so that'll - // need to be added to the URL below if the source changes - computeClientBasePath := config.clientCompute.BasePath - - regionUrl, err := replaceVars(d, config, fmt.Sprintf("%s%s/regions/%s", computeClientBasePath, project, region)) - if err != nil { - return err - } - filter := fmt.Sprintf("(region eq %s)", regionUrl) - + filter := "" if s, ok := d.GetOk("status"); ok { filter += fmt.Sprintf(" (status eq %s)", s) } - call := config.clientCompute.Zones.List(project).Filter(filter) + zones := []string{} + err = config.clientCompute.Zones.List(project).Filter(filter).Pages(config.context, func(zl *compute.ZoneList) error { + for _, zone := range zl.Items { + // We have no way to guarantee a specific base path for the region, but the built-in API-level filtering + // only lets us query on exact matches, so we do our own filtering here. + if strings.HasSuffix(zone.Region, "/"+region) { + zones = append(zones, zone.Name) + } + } + return nil + }) - resp, err := call.Do() if err != nil { return err } - zones := flattenZones(resp.Items) + sort.Strings(zones) log.Printf("[DEBUG] Received Google Compute Zones: %q", zones) d.Set("names", zones) @@ -84,12 +83,3 @@ func dataSourceGoogleComputeZonesRead(d *schema.ResourceData, meta interface{}) return nil } - -func flattenZones(zones []*compute.Zone) []string { - result := make([]string, len(zones)) - for i, zone := range zones { - result[i] = zone.Name - } - sort.Strings(result) - return result -} diff --git a/google/data_source_google_compute_zones_test.go b/google/data_source_google_compute_zones_test.go index 6619ceb07d7..ca73bacab3a 100644 --- a/google/data_source_google_compute_zones_test.go +++ b/google/data_source_google_compute_zones_test.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "strconv" + "strings" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" @@ -18,7 +19,7 @@ func TestAccComputeZones_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckGoogleComputeZonesConfig, + Config: testAccComputeZones_basic, Check: resource.ComposeTestCheckFunc( testAccCheckGoogleComputeZonesMeta("data.google_compute_zones.available"), ), @@ -27,6 +28,24 @@ func TestAccComputeZones_basic(t *testing.T) { }) } +func TestAccComputeZones_filter(t *testing.T) { + t.Parallel() + region := "us-central1" + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: testAccComputeZones_filter(region), + Check: resource.ComposeTestCheckFunc( + testAccCheckGoogleComputeZonesRegion("data.google_compute_zones.available", region), + ), + }, + }, + }) +} + func testAccCheckGoogleComputeZonesMeta(n string) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] @@ -67,6 +86,51 @@ func testAccCheckGoogleComputeZonesMeta(n string) resource.TestCheckFunc { } } -var testAccCheckGoogleComputeZonesConfig = ` +func testAccCheckGoogleComputeZonesRegion(n, region string) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[n] + if !ok { + return fmt.Errorf("Can't find zones data source: %s", n) + } + + if rs.Primary.ID == "" { + return errors.New("zones data source ID not set.") + } + + count, ok := rs.Primary.Attributes["names.#"] + if !ok { + return errors.New("can't find 'names' attribute") + } + + noOfNames, err := strconv.Atoi(count) + if err != nil { + return errors.New("failed to read number of zones") + } + + for i := 0; i < noOfNames; i++ { + idx := "names." + strconv.Itoa(i) + v, ok := rs.Primary.Attributes[idx] + if !ok { + return fmt.Errorf("zone list is corrupt (%q not found), this is definitely a bug", idx) + } + if !strings.Contains(v, region) { + return fmt.Errorf("zone name %q does not contain region %q", v, region) + } + } + + return nil + } +} + +var testAccComputeZones_basic = ` data "google_compute_zones" "available" {} ` + +func testAccComputeZones_filter(region string) string { + return fmt.Sprintf(` +data "google_compute_zones" "available" { + region = "%s" + status = "UP" +} +`, region) +} diff --git a/google/resource_compute_address_sweeper_test.go b/google/resource_compute_address_sweeper_test.go index d79376b1d1e..15b81da3d5a 100644 --- a/google/resource_compute_address_sweeper_test.go +++ b/google/resource_compute_address_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeAddress(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/addresses", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/addresses", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeAddress(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/addresses/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/addresses/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_autoscaler_sweeper_test.go b/google/resource_compute_autoscaler_sweeper_test.go index a5a3e8f1943..fa8294bf621 100644 --- a/google/resource_compute_autoscaler_sweeper_test.go +++ b/google/resource_compute_autoscaler_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeAutoscaler(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/autoscalers", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/autoscalers", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeAutoscaler(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/autoscalers/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/autoscalers/{{name}}" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_backend_bucket_signed_url_key_sweeper_test.go b/google/resource_compute_backend_bucket_signed_url_key_sweeper_test.go index 453217a3901..00bf920f0fb 100644 --- a/google/resource_compute_backend_bucket_signed_url_key_sweeper_test.go +++ b/google/resource_compute_backend_bucket_signed_url_key_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeBackendBucketSignedUrlKey(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{backend_bucket}}", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{backend_bucket}}", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeBackendBucketSignedUrlKey(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{backend_bucket}}/deleteSignedUrlKey?keyName={{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{backend_bucket}}/deleteSignedUrlKey?keyName={{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_backend_bucket_sweeper_test.go b/google/resource_compute_backend_bucket_sweeper_test.go index 7b031bacd6e..573ca3b0f83 100644 --- a/google/resource_compute_backend_bucket_sweeper_test.go +++ b/google/resource_compute_backend_bucket_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeBackendBucket(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeBackendBucket(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendBuckets/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_backend_service_signed_url_key_sweeper_test.go b/google/resource_compute_backend_service_signed_url_key_sweeper_test.go index 510b2bf68d3..317555f99b7 100644 --- a/google/resource_compute_backend_service_signed_url_key_sweeper_test.go +++ b/google/resource_compute_backend_service_signed_url_key_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeBackendServiceSignedUrlKey(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{backend_service}}", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{backend_service}}", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeBackendServiceSignedUrlKey(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{backend_service}}/deleteSignedUrlKey?keyName={{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{backend_service}}/deleteSignedUrlKey?keyName={{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_backend_service_sweeper_test.go b/google/resource_compute_backend_service_sweeper_test.go index ad4a07dd604..7ac12f53a4c 100644 --- a/google/resource_compute_backend_service_sweeper_test.go +++ b/google/resource_compute_backend_service_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeBackendService(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendServices", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendServices", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeBackendService(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/backendServices/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_firewall_sweeper_test.go b/google/resource_compute_firewall_sweeper_test.go index 5c41095ea55..df4445511d7 100644 --- a/google/resource_compute_firewall_sweeper_test.go +++ b/google/resource_compute_firewall_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeFirewall(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/firewalls", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/firewalls", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeFirewall(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/firewalls/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/firewalls/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_forwarding_rule_sweeper_test.go b/google/resource_compute_forwarding_rule_sweeper_test.go index feb50b34aa4..c3167580125 100644 --- a/google/resource_compute_forwarding_rule_sweeper_test.go +++ b/google/resource_compute_forwarding_rule_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeForwardingRule(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/forwardingRules", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/forwardingRules", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeForwardingRule(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/forwardingRules/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_global_address_sweeper_test.go b/google/resource_compute_global_address_sweeper_test.go index 04d2ce78691..17cb015a25e 100644 --- a/google/resource_compute_global_address_sweeper_test.go +++ b/google/resource_compute_global_address_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeGlobalAddress(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/addresses", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/addresses", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeGlobalAddress(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/addresses/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/addresses/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_global_forwarding_rule_sweeper_test.go b/google/resource_compute_global_forwarding_rule_sweeper_test.go index cdc71067fd6..4a5d229abdd 100644 --- a/google/resource_compute_global_forwarding_rule_sweeper_test.go +++ b/google/resource_compute_global_forwarding_rule_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeGlobalForwardingRule(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeGlobalForwardingRule(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/forwardingRules/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_global_network_endpoint_group_sweeper_test.go b/google/resource_compute_global_network_endpoint_group_sweeper_test.go index 366237da499..d8e336ada13 100644 --- a/google/resource_compute_global_network_endpoint_group_sweeper_test.go +++ b/google/resource_compute_global_network_endpoint_group_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeGlobalNetworkEndpointGroup(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/networkEndpointGroups", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/networkEndpointGroups", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeGlobalNetworkEndpointGroup(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/networkEndpointGroups/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/networkEndpointGroups/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_health_check_sweeper_test.go b/google/resource_compute_health_check_sweeper_test.go index 36430f4425c..15133e3ebd5 100644 --- a/google/resource_compute_health_check_sweeper_test.go +++ b/google/resource_compute_health_check_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeHealthCheck(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/healthChecks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/healthChecks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeHealthCheck(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/healthChecks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/healthChecks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_http_health_check_sweeper_test.go b/google/resource_compute_http_health_check_sweeper_test.go index e68cb2f20d5..49377c9d3f1 100644 --- a/google/resource_compute_http_health_check_sweeper_test.go +++ b/google/resource_compute_http_health_check_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeHttpHealthCheck(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeHttpHealthCheck(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/httpHealthChecks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_https_health_check_sweeper_test.go b/google/resource_compute_https_health_check_sweeper_test.go index adbcdceda9a..ef97246b766 100644 --- a/google/resource_compute_https_health_check_sweeper_test.go +++ b/google/resource_compute_https_health_check_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeHttpsHealthCheck(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeHttpsHealthCheck(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/httpsHealthChecks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_image_sweeper_test.go b/google/resource_compute_image_sweeper_test.go index 8870e7faf91..910ac736ea8 100644 --- a/google/resource_compute_image_sweeper_test.go +++ b/google/resource_compute_image_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeImage(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/images", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/images", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeImage(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/images/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/images/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_instance_group_named_port_sweeper_test.go b/google/resource_compute_instance_group_named_port_sweeper_test.go index 07b7008daf1..43fc9505f1f 100644 --- a/google/resource_compute_instance_group_named_port_sweeper_test.go +++ b/google/resource_compute_instance_group_named_port_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeInstanceGroupNamedPort(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/instanceGroups/{{group}}", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/instanceGroups/{{group}}", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeInstanceGroupNamedPort(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/setNamedPorts" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/instanceGroups/{{group}}/setNamedPorts" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_network_endpoint_group_sweeper_test.go b/google/resource_compute_network_endpoint_group_sweeper_test.go index ffa17e1995c..3d789a10764 100644 --- a/google/resource_compute_network_endpoint_group_sweeper_test.go +++ b/google/resource_compute_network_endpoint_group_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeNetworkEndpointGroup(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/networkEndpointGroups", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/networkEndpointGroups", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeNetworkEndpointGroup(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/networkEndpointGroups/{{name}}" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_network_peering.go b/google/resource_compute_network_peering.go index aad41b7b022..99339db8d66 100644 --- a/google/resource_compute_network_peering.go +++ b/google/resource_compute_network_peering.go @@ -257,17 +257,22 @@ func resourceComputeNetworkPeeringImport(d *schema.ResourceData, meta interface{ if len(splits) != 3 { return nil, fmt.Errorf("Error parsing network peering import format, expected: {project}/{network}/{name}") } + project := splits[0] + network := splits[1] + name := splits[2] - // Build the template for the network self_link - urlTemplate, err := replaceVars(d, config, "{{ComputeBasePath}}projects/%s/global/networks/%s") + // Since the format of the network URL in the peering might be different depending on the ComputeBasePath, + // just read the network self link from the API. + net, err := config.clientCompute.Networks.Get(project, network).Do() if err != nil { - return nil, err + return nil, handleNotFoundError(err, d, fmt.Sprintf("Network %q", splits[1])) } - d.Set("network", ConvertSelfLinkToV1(fmt.Sprintf(urlTemplate, splits[0], splits[1]))) - d.Set("name", splits[2]) + + d.Set("network", ConvertSelfLinkToV1(net.SelfLink)) + d.Set("name", name) // Replace import id for the resource id - id := fmt.Sprintf("%s/%s", splits[1], splits[2]) + id := fmt.Sprintf("%s/%s", network, name) d.SetId(id) return []*schema.ResourceData{d}, nil diff --git a/google/resource_compute_network_sweeper_test.go b/google/resource_compute_network_sweeper_test.go index 78970b6101f..b8ad4b569ae 100644 --- a/google/resource_compute_network_sweeper_test.go +++ b/google/resource_compute_network_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeNetwork(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/networks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/networks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeNetwork(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/networks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/networks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_node_group_sweeper_test.go b/google/resource_compute_node_group_sweeper_test.go index 1593c3ff2a3..15ccfb96676 100644 --- a/google/resource_compute_node_group_sweeper_test.go +++ b/google/resource_compute_node_group_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeNodeGroup(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/nodeGroups", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/nodeGroups", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeNodeGroup(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/nodeGroups/{{name}}" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_node_template_sweeper_test.go b/google/resource_compute_node_template_sweeper_test.go index 1a065f7cfe0..eb1b84781ae 100644 --- a/google/resource_compute_node_template_sweeper_test.go +++ b/google/resource_compute_node_template_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeNodeTemplate(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/nodeTemplates", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/nodeTemplates", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeNodeTemplate(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/nodeTemplates/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/nodeTemplates/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_autoscaler_sweeper_test.go b/google/resource_compute_region_autoscaler_sweeper_test.go index c44b2e4a694..6bd90896aa1 100644 --- a/google/resource_compute_region_autoscaler_sweeper_test.go +++ b/google/resource_compute_region_autoscaler_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionAutoscaler(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/autoscalers", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/autoscalers", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionAutoscaler(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/autoscalers/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/autoscalers/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_backend_service_sweeper_test.go b/google/resource_compute_region_backend_service_sweeper_test.go index 81ea2feb7bd..6416a3b8812 100644 --- a/google/resource_compute_region_backend_service_sweeper_test.go +++ b/google/resource_compute_region_backend_service_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionBackendService(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/backendServices", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/backendServices", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionBackendService(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/backendServices/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/backendServices/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_health_check_sweeper_test.go b/google/resource_compute_region_health_check_sweeper_test.go index 2fc6dc911a2..146948aafad 100644 --- a/google/resource_compute_region_health_check_sweeper_test.go +++ b/google/resource_compute_region_health_check_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionHealthCheck(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/healthChecks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/healthChecks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionHealthCheck(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/healthChecks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/healthChecks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_ssl_certificate_sweeper_test.go b/google/resource_compute_region_ssl_certificate_sweeper_test.go index e35e0923d4f..81ea87904f9 100644 --- a/google/resource_compute_region_ssl_certificate_sweeper_test.go +++ b/google/resource_compute_region_ssl_certificate_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionSslCertificate(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/sslCertificates", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/sslCertificates", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionSslCertificate(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/sslCertificates/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/sslCertificates/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_target_http_proxy_sweeper_test.go b/google/resource_compute_region_target_http_proxy_sweeper_test.go index a4969892745..38029f69c8e 100644 --- a/google/resource_compute_region_target_http_proxy_sweeper_test.go +++ b/google/resource_compute_region_target_http_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionTargetHttpProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionTargetHttpProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_target_https_proxy_sweeper_test.go b/google/resource_compute_region_target_https_proxy_sweeper_test.go index eeb6acae8bc..585f4cd0238 100644 --- a/google/resource_compute_region_target_https_proxy_sweeper_test.go +++ b/google/resource_compute_region_target_https_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionTargetHttpsProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpsProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpsProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionTargetHttpsProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetHttpsProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_region_url_map_sweeper_test.go b/google/resource_compute_region_url_map_sweeper_test.go index 99071828f5b..a7cd222c405 100644 --- a/google/resource_compute_region_url_map_sweeper_test.go +++ b/google/resource_compute_region_url_map_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRegionUrlMap(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/urlMaps", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/urlMaps", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRegionUrlMap(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/urlMaps/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/urlMaps/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_reservation_sweeper_test.go b/google/resource_compute_reservation_sweeper_test.go index 30cb767bed3..7dca0d786e7 100644 --- a/google/resource_compute_reservation_sweeper_test.go +++ b/google/resource_compute_reservation_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeReservation(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/reservations", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/reservations", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeReservation(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/reservations/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/reservations/{{name}}" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_resource_policy_sweeper_test.go b/google/resource_compute_resource_policy_sweeper_test.go index 533592c69a7..896372edf97 100644 --- a/google/resource_compute_resource_policy_sweeper_test.go +++ b/google/resource_compute_resource_policy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeResourcePolicy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/resourcePolicies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/resourcePolicies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeResourcePolicy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/resourcePolicies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_route_sweeper_test.go b/google/resource_compute_route_sweeper_test.go index d7aa0e16faf..a7b1767e476 100644 --- a/google/resource_compute_route_sweeper_test.go +++ b/google/resource_compute_route_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRoute(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/routes", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/routes", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRoute(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/routes/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/routes/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_router_bgp_peer_sweeper_test.go b/google/resource_compute_router_bgp_peer_sweeper_test.go index c584f8b7187..475f168842f 100644 --- a/google/resource_compute_router_bgp_peer_sweeper_test.go +++ b/google/resource_compute_router_bgp_peer_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRouterBgpPeer(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRouterBgpPeer(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_router_nat_sweeper_test.go b/google/resource_compute_router_nat_sweeper_test.go index 3b4f4fee6c2..d4af8749dfd 100644 --- a/google/resource_compute_router_nat_sweeper_test.go +++ b/google/resource_compute_router_nat_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRouterNat(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRouterNat(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{router}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_router_sweeper_test.go b/google/resource_compute_router_sweeper_test.go index 11a802d3f6d..79b2266f470 100644 --- a/google/resource_compute_router_sweeper_test.go +++ b/google/resource_compute_router_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeRouter(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeRouter(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/routers/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_snapshot_sweeper_test.go b/google/resource_compute_snapshot_sweeper_test.go index ad43710e0b7..bf5c8e4add9 100644 --- a/google/resource_compute_snapshot_sweeper_test.go +++ b/google/resource_compute_snapshot_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeSnapshot(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/snapshots", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/snapshots", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeSnapshot(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/snapshots/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/snapshots/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_ssl_certificate_sweeper_test.go b/google/resource_compute_ssl_certificate_sweeper_test.go index 1fa681cd91e..ee1fbc32589 100644 --- a/google/resource_compute_ssl_certificate_sweeper_test.go +++ b/google/resource_compute_ssl_certificate_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeSslCertificate(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/sslCertificates", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/sslCertificates", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeSslCertificate(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/sslCertificates/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/sslCertificates/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_ssl_policy_sweeper_test.go b/google/resource_compute_ssl_policy_sweeper_test.go index bdae78e418a..f08b1d10759 100644 --- a/google/resource_compute_ssl_policy_sweeper_test.go +++ b/google/resource_compute_ssl_policy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeSslPolicy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/sslPolicies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/sslPolicies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeSslPolicy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/sslPolicies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/sslPolicies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_subnetwork_sweeper_test.go b/google/resource_compute_subnetwork_sweeper_test.go index 8de326ef272..7dc188afcfb 100644 --- a/google/resource_compute_subnetwork_sweeper_test.go +++ b/google/resource_compute_subnetwork_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeSubnetwork(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/subnetworks", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/subnetworks", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeSubnetwork(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/subnetworks/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/subnetworks/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_target_http_proxy_sweeper_test.go b/google/resource_compute_target_http_proxy_sweeper_test.go index 5ca58cceb9c..7e3d4f34f21 100644 --- a/google/resource_compute_target_http_proxy_sweeper_test.go +++ b/google/resource_compute_target_http_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeTargetHttpProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeTargetHttpProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_target_https_proxy_sweeper_test.go b/google/resource_compute_target_https_proxy_sweeper_test.go index 0a089e4322f..10c6547e477 100644 --- a/google/resource_compute_target_https_proxy_sweeper_test.go +++ b/google/resource_compute_target_https_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeTargetHttpsProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpsProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpsProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeTargetHttpsProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpsProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetHttpsProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_target_instance_sweeper_test.go b/google/resource_compute_target_instance_sweeper_test.go index 23a62f8c47b..829307a2d8d 100644 --- a/google/resource_compute_target_instance_sweeper_test.go +++ b/google/resource_compute_target_instance_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeTargetInstance(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/aggregated/targetInstances", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/aggregated/targetInstances", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -110,7 +110,7 @@ func testSweepComputeTargetInstance(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/targetInstances/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/zones/{{zone}}/targetInstances/{{name}}" if obj["zone"] == nil { log.Printf("[INFO][SWEEPER_LOG] %s resource zone was nil", resourceName) return nil diff --git a/google/resource_compute_target_ssl_proxy_sweeper_test.go b/google/resource_compute_target_ssl_proxy_sweeper_test.go index 3329b5b1a04..6890f86aefc 100644 --- a/google/resource_compute_target_ssl_proxy_sweeper_test.go +++ b/google/resource_compute_target_ssl_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeTargetSslProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeTargetSslProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetSslProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_target_tcp_proxy_sweeper_test.go b/google/resource_compute_target_tcp_proxy_sweeper_test.go index 49a77934ff5..2d028d67cd4 100644 --- a/google/resource_compute_target_tcp_proxy_sweeper_test.go +++ b/google/resource_compute_target_tcp_proxy_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeTargetTcpProxy(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetTcpProxies", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetTcpProxies", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeTargetTcpProxy(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/targetTcpProxies/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/targetTcpProxies/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_url_map_sweeper_test.go b/google/resource_compute_url_map_sweeper_test.go index 628c97360ff..1daebb26527 100644 --- a/google/resource_compute_url_map_sweeper_test.go +++ b/google/resource_compute_url_map_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeUrlMap(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/global/urlMaps", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/global/urlMaps", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeUrlMap(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/global/urlMaps/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/global/urlMaps/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_vpn_gateway_sweeper_test.go b/google/resource_compute_vpn_gateway_sweeper_test.go index f692bf27697..659fcd2fd0a 100644 --- a/google/resource_compute_vpn_gateway_sweeper_test.go +++ b/google/resource_compute_vpn_gateway_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeVpnGateway(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetVpnGateways", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetVpnGateways", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeVpnGateway(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/targetVpnGateways/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_compute_vpn_tunnel_sweeper_test.go b/google/resource_compute_vpn_tunnel_sweeper_test.go index ed43c79c024..3502d0df915 100644 --- a/google/resource_compute_vpn_tunnel_sweeper_test.go +++ b/google/resource_compute_vpn_tunnel_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepComputeVpnTunnel(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/vpnTunnels", "?")[0] + listTemplate := strings.Split("https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/vpnTunnels", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepComputeVpnTunnel(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/vpnTunnels/{{name}}" + deleteTemplate := "https://compute.googleapis.com/compute/v1/projects/{{project}}/regions/{{region}}/vpnTunnels/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_dns_managed_zone_sweeper_test.go b/google/resource_dns_managed_zone_sweeper_test.go index 5f3f9b0459e..3a0e475dcac 100644 --- a/google/resource_dns_managed_zone_sweeper_test.go +++ b/google/resource_dns_managed_zone_sweeper_test.go @@ -61,7 +61,7 @@ func testSweepDNSManagedZone(region string) error { }, } - listTemplate := strings.Split("https://www.googleapis.com/dns/v1/projects/{{project}}/managedZones", "?")[0] + listTemplate := strings.Split("https://dns.googleapis.com/dns/v1/projects/{{project}}/managedZones", "?")[0] listUrl, err := replaceVars(d, config, listTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing sweeper list url: %s", err) @@ -99,7 +99,7 @@ func testSweepDNSManagedZone(region string) error { continue } - deleteTemplate := "https://www.googleapis.com/dns/v1/projects/{{project}}/managedZones/{{name}}" + deleteTemplate := "https://dns.googleapis.com/dns/v1/projects/{{project}}/managedZones/{{name}}" deleteUrl, err := replaceVars(d, config, deleteTemplate) if err != nil { log.Printf("[INFO][SWEEPER_LOG] error preparing delete url: %s", err) diff --git a/google/resource_google_project.go b/google/resource_google_project.go index 21128e44274..6bdf32e732e 100644 --- a/google/resource_google_project.go +++ b/google/resource_google_project.go @@ -429,14 +429,16 @@ func resourceProjectImportState(d *schema.ResourceData, meta interface{}) ([]*sc // Delete a compute network along with the firewall rules inside it. func forceDeleteComputeNetwork(d *schema.ResourceData, config *Config, projectId, networkName string) error { - networkLink, err := replaceVars(d, config, fmt.Sprintf("{{ComputeBasePath}}projects/%s/global/networks/%s", projectId, networkName)) + // Read the network from the API so we can get the correct self link format. We can't construct it from the + // base path because it might not line up exactly (compute.googleapis.com vs www.googleapis.com) + net, err := config.clientCompute.Networks.Get(projectId, networkName).Do() if err != nil { return err } token := "" for paginate := true; paginate; { - filter := fmt.Sprintf("network eq %s", networkLink) + filter := fmt.Sprintf("network eq %s", net.SelfLink) resp, err := config.clientCompute.Firewalls.List(projectId).Filter(filter).Do() if err != nil { return errwrap.Wrapf("Error listing firewall rules in proj: {{err}}", err)