Skip to content

Instantly share code, notes, and snippets.

@plasticbrain
Created February 5, 2014 04:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plasticbrain/8817310 to your computer and use it in GitHub Desktop.
Save plasticbrain/8817310 to your computer and use it in GitHub Desktop.
Get Amazon AWS Instance ID (PHP / wget)
<?php
//---------------------------------------------------------------------------------
// You can get the metadata for an AWS instance by loading the following URL
// Note: This URL must be loaded from an AWS instance
//
//---------------------------------------------------------------------------------
// URL:
// http://169.254.169.254/latest/meta-data/instance-id
//
//---------------------------------------------------------------------------------
// wget:
// wget -q -O - http://169.254.169.254/latest/meta-data/instance-id
//
//---------------------------------------------------------------------------------
echo @file_get_contents("http://instance-data/latest/meta-data/instance-id");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment