[英]AWS: Difference between User data and Metadata tags when creating EC2 instance
Amazon EC2 instances can be created with 'User Data' (a long string), or metadata tags (a number of key/value pairs).可以使用“用户数据”(长字符串)或元数据标签(多个键/值对)创建 Amazon EC2 实例。
What is the difference between these?这些有什么区别? Why do these two systems exist in parallel?
为什么这两个系统并行存在?
In particular, I wish to pass certain pieces of custom data (ie a connection string and two resource URLs) to an EC2 machine on startup so it can configure itself.特别是,我希望在启动时将某些自定义数据(即连接字符串和两个资源 URL)传递给 EC2 机器,以便它可以自行配置。 Presumably these are best sent as three key/value pairs?
大概这些最好作为三个键/值对发送?
According to this documentation page, Metadata provided by Amazon and User Data specified by the user:根据此文档页面,亚马逊提供的元数据和用户指定的用户数据:
Amazon EC2 instances can access instance-specific metadata as well as data supplied when launching the instances.
Amazon EC2 实例可以访问特定于实例的元数据以及启动实例时提供的数据。
You can use this data to build more generic AMIs that can be modified by configuration files supplied at launch time.
您可以使用此数据构建更多通用 AMI,这些 AMI 可以通过启动时提供的配置文件进行修改。 For example, if you run web servers for various small businesses, they can all use the same AMI and retrieve their content from the Amazon S3 bucket you specify at launch.
例如,如果您为各种小型企业运行 Web 服务器,它们都可以使用相同的 AMI 并从您在启动时指定的 Amazon S3 存储桶中检索其内容。 To add a new customer at any time, simply create a bucket for the customer, add their content, and launch your AMI.
要随时添加新客户,只需为客户创建一个存储桶,添加他们的内容,然后启动您的 AMI。
Instance metadata is data use to configure or manage the running instance.实例元数据是用于配置或管理正在运行的实例的数据。 for example, host name, events, and security groups.
例如,主机名、事件和安全组。
User Data specified by the user, for example, you added a new bucked, its unique bucked name will be part of user data.用户指定的User Data ,例如你添加了一个新的bucked,它唯一的bucked名称将成为用户数据的一部分。
Source: https://docs.amazonaws.cn/en_us/AWSEC2/latest/UserGuide/ec2-instance-metadata.html来源: https ://docs.amazonaws.cn/en_us/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
Instance Metadata Service: Get details about EC2 instance from inside an EC2 instance.实例元数据服务:从 EC2 实例内部获取有关 EC2 实例的详细信息。 Such as AMI ID, storage devices, DNS hostname, instance id, instance type, security groups, IPaddresses etc
例如 AMI ID、存储设备、DNS 主机名、实例 ID、实例类型、安全组、IP 地址等
Userdata - Used for bootstrapping.用户数据- 用于引导。 Install OS patches or software when an EC2 instance is launched.
启动 EC2 实例时安装操作系统补丁或软件。
In your following case, you have to use userdata.在以下情况下,您必须使用用户数据。
I wish to pass certain pieces of custom data (ie a connection string and two resource URLs) to an EC2 machine on startup so it can configure itself我希望在启动时将某些自定义数据(即连接字符串和两个资源 URL)传递给 EC2 机器,以便它可以自行配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.