GCP file copy from bucket fails with could not reach metadata service
Asked Answered
P

4

6

Issue - While using the gsutil command to download a file from google bucket with public access from a GCP instance we get the following error

root@openvpn:~# gsutil cp gs://google-artifacts-1/openvpn/openvpn-install.sh /tmp/openvpn-install.sh Failure: Could not reach metadata service: Not Found.

Paunch answered 12/6, 2018 at 9:20 Comment(1)
It might be helpful to rerun the command with debug output enabled: gsutil -D cp gs://...Faugh
D
5

If you are running gcloud/gsutil commands on an instance, and getting error like

Failure: Could not reach metadata service: Not Found.

check instance scopes in "Cloud API access scopes" section in instance details page. There, service you are accessing inside instance should be enabled and instance service account should have proper access to that service.

Doggoned answered 20/8, 2019 at 11:19 Comment(0)
M
2

As of now, that error appears when you haven't authenticated, it's not very accurate at describing what the issue is. Make sure you have issued a "gcloud auth login" before trying the cp.

If that does not solve the issue, do try a "gsutil -D cp gs://google-artifacts-1/openvpn/openvpn-install.sh /tmp/openvpn-install.sh", it's the same command as yours but with the -D flag documented here. That will display debug info.

Cheers,

Miguel.

Mako answered 5/9, 2018 at 15:45 Comment(0)
S
1

If you are:

  • Working from within a Compute Engine instance
  • Using a service account from another project for the CE instance.

Then you need to add roles/iam.serviceAccountTokenCreator to the Compute Engine Service Agent (Service Agents are GCP managed Service Accounts)

Service agent for Compute Engine is: serviceAccount:[email protected]

Sasha answered 28/12, 2023 at 7:3 Comment(0)
C
0

What helped was to activate email service account for compute engine. Ater reboot, it work nicely

Claar answered 21/9, 2022 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.