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.
To retrieve the VM metadata, make an HTTP GET request to one of the following addresses: http://gw/skytap ; the hostname gw automatically maps to the gateway IP address. http://<network-gateway-IP-address>/skytap ; for example, if the gateway IP address is 10.0. 0.254 , use http://10.0.0.254/skytap .
Google Cloud Platform provides a metadata server that knows details about your App Engine instance, such as its containing project ID, service accounts, and tokens used by the service accounts. You can access this data using simple HTTP requests: no client libraries are required.
What is the gcloud CLI? The Google Cloud CLI is a set of tools to create and manage Google Cloud resources. You can use these tools to perform many common platform tasks from the command line or through scripts and other automation.
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)'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With