[ec2-beta] Newbie Questions: user-data scripts

Eric Hammond ehammond at thinksome.com
Sat Jan 3 03:43:32 GMT 2009


Steve:

The user-data scripts are specified at the time you run the instance, so 
that would be client-side I suppose.

Unfortunately, the current official Ubuntu beta AMI seems to be broken 
when it tries to run the user-data script.  I've submitted a bug report 
(LP#313371).

I believe the intention is for the official Ubuntu user-data scripts to 
work exactly as they do with the unofficial Ubuntu AMIs I list on 
http://alestic.com which folks are using in production.  The remainder 
of this email describes how to use this functionality.

The method for specifying user-data depends on the EC2 API client you 
use.  With the EC2 Firefox plugin, you can paste it in to "User Data" or 
click "Open File".  With the EC2 API command line tools, you can use the 
--user-data or --user-data-file options.

I have attached a sample user-data script which installs WordPress. 
Caveat: I don't use WordPress personally so this mostly follows an 
example from the Ubuntu community documentation.

1. Save this file as, say, "install-wordpress"

2. Start up an instance of Ubuntu 8.10 Intrepid (unofficial community 
AMI) with the user-data file:

   ec2-run-instances                    \
     --user-data-file install-wordpress \
     --key YOURKEYPAIR                  \
     ami-1a5db973

(Always use the latest AMI id as listed on http://alestic.com or the 
latest official Ubuntu AMI id especially if you are reading this after 
January 2009.)

3. Optional: You can ssh to the instance and watch the install progress with

   tail -f /var/log/syslog

4. When the install has completed, you can access and configure 
WordPress by visiting the instance external host name in your web browser.

   http://ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com

--
Eric Hammond
ehammond at thinksome.com



Steve Venditti wrote:
> Thanks for the reply. I too have just starting using the beta
> distribution and have been using the approach #2 below. I was not
> aware of the first approach you mention, "If you run an instance
> 
> passing in user-data starting with #! then the instance will run this
> 
> script on boot". Can you give an example regarding how this would
> work? Does the user-data script live server-side or client-side?
> 
> Also, I would like to say great work on the alestic AMIs.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: install-wordpress
Url: https://lists.ubuntu.com/mailman/private/ec2/attachments/20090102/33f2dc11/attachment-0001.diff 


More information about the Ec2-beta mailing list