junsid
junsid

Reputation: 355

gcloud command to retrieve metadata of a specific key

Is there any way to retrieve custom instance metadata value for a specific key ? I tried gcloud compute instances describe instance-1 command, this return whole meta data text. But i just want to retrieve the value of a specific key only.

Upvotes: 12

Views: 9114

Answers (1)

Jofre
Jofre

Reputation: 3898

The gcloud tool has built-in filters and formats, for details you can read gcloud topic filters, gcloud topic formats, and gcloud topic projections.

For your specific use case, you can get the metadata value with:

gcloud compute instances describe INSTANCE-ID \
  --format='value[](metadata.items.YOUR-KEY)'

Upvotes: 17

Related Questions