EC2:从实例本身获得实例ID [英] EC2: get instance id from within the instance itself

查看:725
本文介绍了EC2:从实例本身获得实例ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/625644/find-out-the-instance-id-from-within-an-ec2-machine">Find从内EC2机实例ID

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

我要寻找找到一个实例的ID从这个例子本身最简单的方法。

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

我看了看shell变量:没有运气。 我怎样才能得到它?

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

我唯一的解决方案,现在的问题是要写入的Java API(1)来描述实例,(2),以找到一个匹配的IP地址或DNS,并获得其ID。什么简单?

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 ?

感谢

迪迪埃

推荐答案

您可以使用<一个href="http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?AESDG-chapter-instancedata.html">Instance元数据API 来获取实例ID。只需从实例中做一个HTTP GET请求 http://169.254.169.254/latest/meta-data/instance-id

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.

这篇关于EC2:从实例本身获得实例ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆