Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 802
rohan gupta Avatar asked Jun 12 '18 09:06

rohan gupta


2 Answers

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.

like image 110
DSdatsme Avatar answered Sep 28 '22 06:09

DSdatsme


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.

like image 27
Mike Perez Ontiveros Avatar answered Sep 28 '22 07:09

Mike Perez Ontiveros