Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon ec2 user-data, how does it work?

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?

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.

User data screenshot: http://d.pr/GZlY

like image 550
Devrim Avatar asked Mar 19 '12 02:03

Devrim


People also ask

How does EC2 user data work?

When you launch an instance in Amazon EC2, you have the option of passing user data to the instance that can be used to perform common automated configuration tasks and even run scripts after the instance starts. You can pass two types of user data to Amazon EC2: shell scripts and cloud-init directives.

What is AWS instance user data?

AWS userdata is the set of commands/data you can provide to a instance at launch time. For example if you are launching an ec2 instance and want to have docker installed on the newly launched ec2, than you can provide set of bash commands in the userdata field of aws ec2 config page. Usecase. Automated deployments.

What is the purpose of Amazon Elastic Compute Cloud Amazon EC2 user data?

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) Cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.


1 Answers

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

See also:

  • http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html

  • http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

like image 194
Eric Hammond Avatar answered Oct 03 '22 00:10

Eric Hammond