July 2018
Intermediate to advanced
506 pages
16h 2m
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