Skip to content

Instantly share code, notes, and snippets.

@duggan
Created September 18, 2012 15:24
Show Gist options
  • Save duggan/3743738 to your computer and use it in GitHub Desktop.
Save duggan/3743738 to your computer and use it in GitHub Desktop.
EC2 Info
<?php
$base = "http://169.254.169.254/latest/";
$metadata = array("instance-id", "hostname", "instance-type", "public-hostname", "security-groups",
"ami-id", "ami-launch-index", "ami-manifest-path", "kernel-id","mac","reservation-id"
);
echo "<style>td{white-space:nowrap;}</style>";
echo "<table>";
foreach ($metadata as $info) {
echo "<tr>";
$url = $base . "meta-data/" . $info;
echo "<td>$info:</td>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
echo "<td>" . curl_exec($ch) . "</td>";
curl_close($ch);
echo "</td>";
}
$url = $base . "user-data";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$userdata = curl_exec($ch);
curl_close($ch);
echo "<tr><td>&nbsp;</td><td>";
echo "<pre>" . $userdata . "<pre>";
echo "</td></tr>";
echo "</table>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment