hashicorp / terraform-provider-google

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

Advanced routing rules are not supported for scheme EXTERNAL, invalid #8307

Closed dsdshcym closed 3 years ago

dsdshcym commented 3 years ago

Community Note

Terraform Version

terraform -v
Terraform v0.12.30
+ provider.aws v3.25.0
+ provider.google v3.53.0
+ provider.google-beta v3.54.0

Affected Resource(s)

Terraform Configuration Files

resource "google_compute_url_map" "stream" {
  name            = "stream-url-map-${var.environment}"
  default_service = google_compute_backend_bucket.stream.self_link

  host_rule {
    hosts        = ["*"]
    path_matcher = "allpath"
  }

  path_matcher {
    name            = "allpath"
    default_service = google_compute_backend_bucket.stream.id

    route_rules {
      priority = 1
      service  = google_compute_backend_service.external-server.id

      match_rules {
        regex_match = ".*\\.m3u8$"
      }
    }
  }
}

Debug Output

Expected Behavior

As @edwardmedia explained in https://github.com/hashicorp/terraform-provider-google/issues/6634#issuecomment-650266253,

routeRules should work for External load balancers now

So I expect advanced routing rule to be added without an error

Actual Behavior

Tried both provider google and provider google-beta, with both providers I got an error like this:

    Error: Error updating UrlMap "***url_map_id***": googleapi: Error 400: Invalid value for field 'resource.pathMatchers[0].routeRules[0].service': '***external_service_id***'. Advanced routing rules are not supported for scheme EXTERNAL, invalid

Steps to Reproduce

  1. terraform apply

References

edwardmedia commented 3 years ago

@dsdshcym can you share the full debug log along with the configs for backend service and backend bucket?

edwardmedia commented 3 years ago

@dsdshcym is this still an issue?

dsdshcym commented 3 years ago

Hi @edwardmedia!

Sorry for the late reply.

I can't share the full debug log... But I can share what I found:

url map has not supported regex_match for an external backend service. I tested it with gcloud cli with the following yaml config:

defaultService: backendBucket
kind: compute#urlMap
name: url-map-testing
hostRules:
  - hosts:
      - "*"
    pathMatcher: allpath
pathMatchers:
  - defaultService:   backendBucket
    name: allpath
    routeRules:
      - matchRules:
          - regexMatch: ".*\\.m3u8"
        priority: 0
        service: externalBackendBucket

and gcloud compute url-maps import ... returns the same error:

ERROR: (gcloud.compute.url-maps.import) HTTPError 400: Invalid value for field 'resource.pathMatchers[0].routeRules[0].service':'...'. Advanced routing rules are not supported for scheme EXTERNAL

so this issue is not terraform's fault.

I also confirmed that url-rewrite, query_parameter_matches and header_matches now work with external backend services.

I'd wish we can update the route_rules doc (https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_url_map#route_rules) to make it explicit (it's not fully supported by GCP yet)

edwardmedia commented 3 years ago

@dsdshcym generally the Terraform provider document is based on the GCP APIs. If you found the missing pieces that exist in the API documents, please let us know. Closing this issue then. Feel free to reopen it if you need to continue the conversation

ghost commented 3 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!