简体   繁体   English

AWS:创建 EC2 实例时用户数据和元数据标签之间的区别

[英]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.

相关问题 AWS Workspaces和启用RDP的EC2实例之间有什么区别? - What is the difference between AWS Workspaces and a RDP enabled EC2 instance? 在 aws ec2 实例上创建用户并添加公钥 - Creating a user and adding public key on aws ec2 instance 连接两个 AWS EC2 实例以将数据从一个 EC2 实例共享到另一个 EC2 实例 - Connect between two AWS EC2 Instances to share data from one EC2 instance to other EC2 instance 将脚本作为用户数据传递到AWS EC2 spot实例 - Passing script as user data into AWS EC2 spot instance AWS EC2 实例用户数据 bash 脚本不起作用 - AWS EC2 instance user data bash script not working AWS EC2 Windows 实例用户数据和任务计划程序 - AWS EC2 Windows Instance User Data and Task Scheduler 从AWS CLI启动EC2实例时未执行用户数据脚本 - User-data script not executed when starting EC2 instance from AWS CLI 运行 ec2 实例的用户数据时出现 aws 凭据错误 - Getting a aws credentials error when I run user data of ec2 instance 无法在实例元数据关闭的情况下将 SSH 插入 AWS EC2 实例 - Unable to SSH into AWS EC2 instance with instance metadata turned off AWS Cloudformation:如何在创建EC2时重用放在user-data参数中的bash脚本? - AWS Cloudformation: How to reuse bash script placed in user-data parameter when creating EC2?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM