8

Possible Duplicate:
Find out the instance id from within an ec2 machine

I am looking for the simplest way to find the id of an instance from within this instance itself.

I looked at the shell variables: no luck. How can I get it ?

My only solution right now is to write to the java api (1) to describe instances and (2) to finding the one matching ip address or dns and get its id. Anything simpler ?

thanks

didier

Community
  • 1
  • 1
Didier Durand
  • 627
  • 7
  • 16

1 Answers1

13

You can use the Instance Metadata API to retrieve the instance ID. Simply make a HTTP GET request to http://169.254.169.254/latest/meta-data/instance-id from within the instance.

bdonlan
  • 224,562
  • 31
  • 268
  • 324