Skip to content

Instantly share code, notes, and snippets.

@seanjensengrey
Last active May 10, 2021 16:02
Show Gist options
  • Save seanjensengrey/1ab4f6edb375ee7a698ef2968a97aa0c to your computer and use it in GitHub Desktop.
Save seanjensengrey/1ab4f6edb375ee7a698ef2968a97aa0c to your computer and use it in GitHub Desktop.

Instance level metadata urls

Both AWS and GCP, probably Azure as well, offer the ability to query instance level metadata from within the guest (and container)

GCP

https://cloud.google.com/compute/docs/storing-retrieving-metadata#querying

curl "http://metadata.google.internal/computeMetadata/v1/instance"

root@5f9f3662a783:/# curl -vv "http://metadata.google.internal/computeMetadata/v1/instance"
*   Trying 169.254.169.254:80...
* TCP_NODELAY set
* Connected to metadata.google.internal (169.254.169.254) port 80 (#0)
> GET /computeMetadata/v1/instance HTTP/1.1
> Host: metadata.google.internal
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: BaseHTTP/0.3 Python/2.7.13
< Date: Mon, 10 May 2021 15:55:56 GMT
< Content-Type: application/text
< Metadata-Flavor: Google
<
attributes/
cpu-platform
description
disks/
guest-attributes/
hostname
id
image
legacy-endpoint-access/
licenses/machine-typemaintenance-eventnamenetwork-interfaces/preemptedremaining-cpu-timescheduling/
service-accounts/
tags
virtual-clock/
zone
* Closing connection 0

AWS

on AWS, https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html

root@5f9f3662a783:/# curl -vv http://169.254.169.254/latest/meta-data/
*   Trying 169.254.169.254:80...
* TCP_NODELAY set
* Connected to 169.254.169.254 (169.254.169.254) port 80 (#0)
> GET /latest/meta-data/ HTTP/1.1
> Host: 169.254.169.254
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 404 Not Found
< Server: BaseHTTP/0.3 Python/2.7.13
< Date: Mon, 10 May 2021 15:53:25 GMT
< Content-Type: text/html; charset=UTF-8
< Metadata-Flavor: Google
<
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/latest/meta-data/</code> was not found on this server.  <ins>That’s all we know.</ins>
* Closing connection 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment