Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

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 (i.e. a connection string and two resource URLs) to an EC2 machine on startup so it can configure itself. Presumably these are best sent as three key/value pairs?

like image 937
Jason Crease Avatar asked May 12 '26 05:05

Jason Crease


2 Answers

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.

You can use this data to build more generic AMIs that can be modified by configuration files supplied at launch time. 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. To add a new customer at any time, simply create a bucket for the customer, add their content, and launch your AMI.

like image 80
Valery Lisay Avatar answered May 13 '26 22:05

Valery Lisay


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.

Source: https://docs.amazonaws.cn/en_us/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

like image 27
Rishabh Agarwal Avatar answered May 13 '26 22:05

Rishabh Agarwal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!