Ville
Ville

Reputation: 494

Load balancer giving failed_to_pick_backend with internet network endpoint group

I have a load balancer setup pointing to an external url via internet network endpoint group (internet NEG)

Now the load balancer returns 502 status code & I see failed_to_pick_backend in the logs. Also the monitoring tab of the load balancer shows INVALID_BACKEND next to the internet NEG I've defined. I've attached screenshots of the view for clarity, latter one is the one that's failing. I've checked the NEGs and they seem identical.

working example

enter image description here

All the suggestions so far mention fixing health checks, but as seen from the docs, internet NEGs does not support health checks. I was able to create working setup through the UI, but when replicating the setup via terraform, things starts to fail. The only difference I saw was that the setup done via UI, the appropriate forwarding rule had ipVersion: IPV4, but that was not possible to setup through terraform since it takes either ipVersion or ip and I gave the resource ip.

So, what could cause failed_to_pick_backend & INVALID_BACKEND with setup like mine?

Upvotes: 1

Views: 1083

Answers (1)

Ville
Ville

Reputation: 494

I found the answer to my question from another post: https://serverfault.com/a/1065279/965524

google_compute_global_network_endpoint needs to be created before google_compute_backend_service is created so you need to set depends_on = [google_compute_global_network_endpoint.endpoint] to your google_compute_backend_service. Otherwise you will hit errors like described in the question.

Upvotes: 1

Related Questions