Reputation: 2152
I'm running some tests on different Compute Engine instances of various types and I'd like to get a machine type of the instance the testing script is currently running on to distinguish the results.
Is this possible with gcloud
or some API call?
Upvotes: 5
Views: 3114
Reputation: 26548
Simply use the gcloud command to describe the instance:
$ gcloud compute instances describe <instance> --zone <zone> --format='table(machineType)'
or the instances.get API.
Upvotes: 3
Reputation: 3129
You can query the metadata server exposed to every Compute Engine VM instance for that. Running something like
wget -q -O - --header Metadata-Flavor:Google metadata/computeMetadata/v1/instance/machine-type
in a VM will print a string like projects/13236423431/machineTypes/n1-standard-2
.
Upvotes: 9