Skip to content

Instantly share code, notes, and snippets.

@Matrix7867
Created February 5, 2020 06:47
Show Gist options
  • Save Matrix7867/3ed85cc91d0ebf2fed65946894d43755 to your computer and use it in GitHub Desktop.
Save Matrix7867/3ed85cc91d0ebf2fed65946894d43755 to your computer and use it in GitHub Desktop.
Getting hostname from GCP instance via curl into metadata
#Getting hostname of the instance via Metadata
curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google"
#Getting ID of the instance
curl http://metadata.google.internal/computeMetadata/v1/instance/id -H "Metadata-Flavor: Google"
#Getting Instance-name via Metadata
curl http://metadata.google.internal/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment