Amazon ec2 用户数据,它是如何工作的? [英] Amazon ec2 user-data, how does it work?
问题描述
我们正在启动实例,并访问我们放置的用户数据.但是有人了解这个操作的内部结构吗(亚马逊方面)?当我们传入用户数据时,数据是在什么时候传输到虚拟机的(这是一个 Xen 特性),它存储在哪里?
We are starting instances, and accessing the user-data we place. But does anybody understand the internals of this operation (from Amazon's side)? When we pass in the user-data, at what point is that data transmitted to the VM (is this a Xen feature) and where is it stored?
我首先想到的是,它被设置为 USER_DATA env var,但我们也可以将其作为文件传递.该文件存储在哪里?它适用于所有实例还是因 AMI 而异?
I first thought, it was set as the USER_DATA env var, but we can also pass it as a file. Where is that file stored? Is it generic to all instances or varies depending on AMI?
这本身不是问题,只是想知道亚马逊是如何做到的.
This is not a problem per se, just wanted to know how Amazon does this.
用户数据截图:http://d.pr/GZlY
推荐答案
用户数据可通过以下 URL 的简单 HTTP 请求提供给实例:
The user-data is available to the instance with a simple HTTP request at this URL:
http://169.254.169.254/latest/user-data
Amazon EC2 不会直接将此用户数据放在实例上,尽管许多 AMI 具有指示实例自动下载和处理用户数据的代码.
Amazon EC2 does not put this user-data on the instance directly, though many AMIs have code that instructs the instance to download and process the user-data automatically.
另见:
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html
这篇关于Amazon ec2 用户数据,它是如何工作的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!