Search code examples
gcloud

gcloud compute backend-services provides a "not found" error


For some unclear reason the gcloud compute backend-services does not find a resource even it is listed. I run the command:

gcloud compute backend-services list

And get the output:

NAME                                                     BACKENDS                                                                                     PROTOCOL
k8s1-48550837-defaul-reverse-proxy-captcha-s-8-9edaabba  us-central1-c/networkEndpointGroups/k8s1-48550837-defaul-reverse-proxy-captcha-s-8-9edaabba  HTTP
k8s1-48550837-default-admission-service-80-ccc76f21      us-central1-c/networkEndpointGroups/k8s1-48550837-default-admission-service-80-ccc76f21      HTTP
k8s1-48550837-default-agent-service-80-46302173          us-central1-c/networkEndpointGroups/k8s1-48550837-default-agent-service-80-46302173          HTTP
k8s1-48550837-default-authproxy-service-80-f50b4f37      us-central1-c/networkEndpointGroups/k8s1-48550837-default-authproxy-service-80-f50b4f37      HTTP

But for any one of the backends I am trying to get description or edit, I get error. For example, this command:

gcloud compute backend-services describe k8s1-48550837-default-agent-service-80-46302173

returns error:

ERROR: (gcloud.compute.backend-services.describe) Could not fetch resource:
 - The resource 'projects/radware-cto/regions/us-central1/backendServices/k8s1-48550837-default-agent-service-80-46302173' was not found

Solution

  • OP confirmed --global works in a comment.

    The reason this works is because the 'describe' command will by default describe the resource in the default compute/region (gcloud config set compute/region...)

    You can see this in your error message:
    - The resource .../regions/us-central1/backendServices/...

    However, as this resource is global, we need to specify --global flag to override the default region.

    Additional information here