Open segevfiner opened 1 week ago
Confirmed issue!
The argument is not in terraform registry, but it exists on the API as pathMatchers[].routeRules[].customErrorResponsePolicy
.
When trying to use a custom_error_response_policy
inside a route_rules
block it returns the message: Unexpected block: Blocks of type "custom_error_response_policy" are not expected here
. Example:
resource "google_compute_http_health_check" "http_hc_20100" {
provider = google-beta
name = "http-hc-20100"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
resource "google_compute_backend_service" "backend_service_20100" {
provider = google-beta
name = "backend-service-20100"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10
load_balancing_scheme = "EXTERNAL_MANAGED"
health_checks = [google_compute_http_health_check.http_hc_20100.id]
}
resource "google_storage_bucket" "sb_20100" {
provider = google-beta
name = "sb-20100"
location = "US"
}
resource "google_compute_backend_bucket" "backend_bucket_20100" {
provider = google-beta
name = "backend-bucket-20100"
bucket_name = google_storage_bucket.sb_20100.name
enable_cdn = true
}
resource "google_compute_url_map" "url_map_20100" {
provider = google-beta
name = "url-map-20100"
default_service = google_compute_backend_service.backend_service_20100.id
host_rule {
hosts = ["mysite.com"]
path_matcher = "mysite"
}
path_matcher {
name = "mysite"
default_service = google_compute_backend_bucket.backend_bucket_20100.id
route_rules {
match_rules {
path_template_match = "/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}"
}
service = google_compute_backend_service.backend_service_20100.id
priority = 1
route_action {
url_rewrite {
path_template_rewrite = "/{username}-{cartid}/"
}
}
}
route_rules {
match_rules {
path_template_match = "/xyzwebservices/v2/xyz/users/*/accountinfo/*"
}
service = google_compute_backend_service.backend_service_20100.id
priority = 2
custom_error_response_policy {
error_response_rule {
match_response_codes = ["4xx"] # Catch all 4xx responses under /private/*
path = "/login.html" # Serve /login.html from the error service
override_response_code = 401
}
error_service = google_compute_backend_bucket.backend_bucket_20100.id
}
}
}
}
Community Note
Terraform Version & Provider Version(s)
Terraform v1.9.8 on
Affected Resource(s)
google_compute_url_map
Terraform Configuration
Debug Output
No response
Expected Behavior
The field should exist the same as it exists for
pathRules
.Actual Behavior
It doesn't.
Steps to reproduce
Try to create a
google_compute_url_mapwith the field
pathMatchers[].routeRules[].customErrorResponsePolicy`Important Factoids
It exists for
pathRules
it was probably forgotten forrouteRules
References
b/377733707