March 2019
Beginner to intermediate
778 pages
34h 20m
English
Metadata API behavior can be modified using query parameters. To have the API return all nested values recursively, simply provide the ?recursive=true query parameter. To specify the response format as either plain text or JSON, provide the ?alt=<text|json> query parameter. This makes it possible to retrieve an instance's entire metadata using the following command:
gcloud compute ssh --zone=us-east1-b hello-gce --command \ 'curl -s -H "Metadata-Flavor: Google" \ "http://metadata.google.internal/computeMetadata/v1/instance/?recursive=true&alt=json"' \ | python -m json.tool
Read now
Unlock full access