Below is my terraform script. I have set up the necessary forwarding rules and target http proxies. Also the backend services exist. I am able to access all paths under /images/*
, however, I can’t access the paths under /videos/*
. From the script, the dafault backend service is backend-lb-prod
which is the backend service where the path /images/*
exists. I switched the default backend service to backend-lb
, I could now access /videos/*
but not /images/*
.
resource "google_compute_url_map" "url-map-be" {
name = "${var.platform_name}-url-map-be-prod"
default_service = "${google_compute_backend_service.backend-lb-prod.self_link}"
host_rule {
hosts = ["${var.backend_address_name}"]
path_matcher = "allpaths"
}
path_matcher {
name = "allpaths"
default_service = "${google_compute_backend_service.backend-lb-prod.self_link}"
path_rule {
paths = [“/images"]
service = "${google_compute_backend_service.backend-lb-prod.self_link}"
}
path_rule {
paths = [“/images/*"]
service = "${google_compute_backend_service.backend-lb-prod.self_link}"
}
path_rule {
paths = ["/videos"]
service = "${google_compute_backend_service.backend-lb.self_link}"
}
path_rule {
paths = ["/videos/*"]
service = "${google_compute_backend_service.backend-lb.self_link}"
}
}
}
When I run the tests for the url map on the google console, this is the error I get
Invalid value for field 'resource': ''. Test failure: Expect URL ‘*.*.*.*/videos/go'
to map to service ‘***93-BACKEND_SERVICE-**-backend-lb', but actually mapped to
'***93-BACKEND_SERVICE-**-backend-lb-prod’.
This is how google_compute_url_map
in the terraform documentation is illustrated. What am I missing in this case.
update
I have included the /videos
and /images
paths and the error above is gone. However, from the logs of the application, the traffic is still sent through the default backend service.