1

I am in google cloud, in google compute engine.

I am inside an instance in a managed instance group, What is the best command for giving me the output of...

gcloud compute instances describe my-instance-group-ab12 --zone=us-central1-b

... about the current machine, without having to provide the instance name? Something similar to this concept:

gcloud compute instances describe self

I just made that command up, just to communicate what I am after.

Thank you for your help

santiago arizti
  • 435
  • 6
  • 16

1 Answers1

1

Generally you can use /usr/share/google/get_metadata_value to get most metadata and construct a command from there if more is required.

Example:

/usr/share/google/get_metadata_value

/usr/share/google/get_metadata_value name

/usr/share/google/get_metadata_value disks/

Mario
  • 31
  • 4
  • sounds like it should work, but I don't have those folders in my google compute engine instance, it was built with the google image of debian stretch (9), and for what I read int he documentation, that directory is the old way of doing things: https://cloud.google.com/compute/docs/startupscript – santiago arizti May 03 '18 at 00:20
  • sounds like this is an alternative but this requires making http requests... I would think the information lived on th server itself... https://cloud.google.com/compute/docs/storing-retrieving-metadata – santiago arizti May 03 '18 at 00:30
  • 1
    The old script actually does http requests to the metadata server. AFAIK no data lives in the instance itself. – Mario May 03 '18 at 08:28