How To: Getting Started with Amazon EC2

April 5, 2008

Amazon EC2 is among the more potent items in Amazon’s web services arsenal. You’ve probably heard of many of the other services such as S3 for storage and FPS for payments. EC2 is all about the “elastic compute cloud.” In layman’s terms, it’s a server. In slightly less layman’s terms, EC2 lets you easily run and manage many instances (like servers) and given the proper software and configurations, have a scalable platform for your web application, outsource resource-intensive tasks to EC2 or for whatever you would use a server farm.

There are three different sizes of EC2 instances you can summon and they’re all probably more powerful than the server currently running your blog. Unless you’re offloading video processing or something intense to EC2, the default small instance with its 1.7GB of RAM and 160GB disk should be more than fine. It’s just nice to know that if for any reason I need a farm of machines each with 15GB of RAM, I can get that easily.

EC2 has been around for a while but has gained interest in the last few weeks as Amazon released an elastic IP feature. One of the larger EC2 issues deals with data persistence on instances. There are many limitations with EC2 that make it difficult to use unless you carefully build around the EC2 architecture and don’t just assume that you can move your app to EC2 flawlessly. If an instance crashes and you run it again, you’ll loose data and when the instance comes back up it will have a new IP, adding another hurdle with DNS issues. Fortunately, the elastic IP feature lets you assign a static IP address to your instances.

As the title of this article implies, this article is meant to be a beginner’s look into tinkering with EC2. Just because you will be able to host a page on EC2 at the end of this article does not mean you should start using it as your only server. Many considerations need to be made when using EC2 to get around the data persistence issue. If your startup is looking to use EC2 as a scalable platform, fortunately there are many services that have already built stable systems on top of EC2, ready for your consumption: WeoCeo, Scalr and RightScale. Enough talk, shall we jump right in?

Note: Most of the information below (and more) is available in the EC2 API doc if you enjoy reading those things.

Getting Started

In order to interact with any EC2 instances, you’ll need to install Amazon’s command line tools and download your X.509 certificate from Amazon. Let’s start with the certificate. Login to your Amazon account and visit the AWS Access Identifiers page. In the X.509 certificate section near the bottom, click Create New. You’ll be greeted with a page allowing you to download both the private key file and X.509 certificate. Both of these are very important, download them to your desktop so you don’t lose them.

Amazon AWS - Create X.509 Certificate

Next up, grab the EC2 command line tools. Extract them and you should be left with a folder named something like ec2-api-tools-1.3-19403. We’ll move those to a directory where we will also store the private and public keys.

The commands below assume you are working on an OS X machine in the Terminal.


mkdir ~/.ec2
cd ~/Desktop
mv *.pem ~/.ec2
cd ~/Desktop/ec2-api-tools-1.3-19403/ #depends on ec2 tools folder name
mv * ~/.ec2

This is what your .ec2 folder should have now.

Amazon EC2 Folder

Next up, we’ll set some paths in your bash profile so the OS knows where the EC2 tools are located.

sudo vi ~/.bash_profile

Add these lines, replacing “YOURKEYNAME” with the actual file name of your private and public keys, then save.


export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin
export EC2_PRIVATE_KEY=pk-YOURKEYNAME.pem
export EC2_CERT=cert-YOURKEYNAME.pem
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/

To get the changes noticed by the OS immediately, run source.

source ~/.bash_profile

Now we can actually use those helpful EC2 command line tools.

AMIs, Keypairs and Instances, Oh My!

Before proceeding, you’ll need to grok the concept of AMIs. They are Amazon Machine Images and whenever you create an EC2 instance, an AMI is quickly loaded on the machine. They’re essentially images of the OS. If you terminate an instance and bring it up again, your machine will only have the data initially included in the image. That’s why lots of work goes into making (“bundling”) a good image you will always use that has the configurations and software you need so you don’t have to do much whenever you load the image. This article won’t delve into creating your own AMIs but fortunately there are many great, public AMIs available for use.

To SSH into the instance we’ll create from an AMI we find, we’ll need to create a keypair. This is a different key from the one provided to us by Amazon. That was for using the EC2 tools and interacting with the instances in terms of creation and management. To actually SSH into an instance, a separate keypair is required as there are no passwords by default.


cd ~/.ec2 #we pretty much always need to be here
ec2-add-keypair pstam-keypair

That will print out the private key, which you’ll need to copy and paste into a file manually.

Amazon EC2 - Adding a keypair


vi ~/.ec2/id_rsa-pstam-keypair
#now paste the private key and save
sudo chmod 600 id_rsa-pstam-keypair

Now we can find which AMI we want to toss on our yet-to-be-created EC2 instance.


cd ~/.ec2
ec2-describe-images -a

Using the -a option will list all of the AMIs you have access to, and there are a lot. Alternatively you can list just the images Amazon has:


ec2-describe-images -o amazon

Amazon EC2 AMIs

I found an AMI that I’ll try out.

ami.yyang.info/gentoo-nginx-php-mysql-06feb2008.manifest.xml

It’s a Gentoo Linux install with PHP, MySQL and nginx. When looking at AMIs, you need to find the AMI ID. In this case, it’s ami-6138dd08.


ec2-run-instances ami-6138dd08 -k pstam-keypair

The instance is now being loaded with the AMI I selected and booting up. It should output some text with “RESERVATION” and “INSTANCE” rows. On the instance row, it will say something like pending pstam-keypair until it has fully booted up. When an instance is ready to go, its URL and internal address will be supplied with the ec2din command below.


ec2-describe-instances

Amazon EC2 Describe Instances

If you try to access the URL in a browser, nothing will happen just yet as the firewall blocks all ports by default. You’ll have to open up the ones you need. We’ll do port 80 for HTTP and 22 for SSH. If the AMI you are running doesn’t have a web server installed, accessing the EC2 URL in a browser won’t bring up anything regardless.


ec2-authorize default -p 22
ec2-authorize default -p 80

If you want to undo any port authorizations you’ve made, you can use ec2-revoke. Now if you access your EC2 URL in a browser you’ll get something like a default Apache page, or in the case of the AMI I’m using, a phpinfo() page.

EC2 Instance loaded in Firefox

The next step to actually using your new EC2 instance is SSHing into it to get full root access. Run the line below and replace the EC2 URL with the one provided to you by the ec2-describe-images command earlier.


ssh -i id_rsa-pstam-keypair root@ec2-XXX-XXX-XXX-XXX.z-2.compute-1.amazonaws.com

If you run into the problem I did, this won’t work and you’ll be asked for an EC2 instance password that doesn’t exist. I found out this was because I initially created the id_rsa-pstam-keypair file as the root user but ran the ssh command as a regular user which was not able to access that keypair. That was easily fixed with sudo chown Paul id_rsa-pstam-keypair but you won’t have this issue if you followed this guide.

Otherwise, you should be logged into your EC2 instance as root over SSH. Now that we’re in, we can tinker with the system however we like and even see what kind of hardware we’re running on, setup FTP and drop a web app into /var/www/localhost/htdocs or whatever. Having full root access in any OS you wish is one of the boons of using Amazon EC2.

SSHed into EC2 Instance - cpuinfo

Static IP Time

If you plan on running your instance for good, you’ll want a static IP. Let’s get one for you.


ec2-allocate-address

Amazon EC2 - Allocate IP

Now we just need to tie that IP address to the instance ID of the instance you wish to give a static IP. You can grab the instance ID (not to be confused with the ami-* AMI ID) by running ec2-describe-instances.

In the line below, replace XXX.XXX.XXX.XXX with the IP address you were given above and replace i-yourinstance with your actual instance ID.


ec2-associate-address -i i-yourinstance XXX.XXX.XXX.XXX

Amazon EC2 Associate IP Address

Give it a few minutes and your instance will be accessible through that new IP in addition to the longer EC2 URL we were previously using. Please note that if you terminate the instance, the IP does not remain tied to the instance, to the best of my knowledge. Terminating an instance seems to be a nuclear option compared to simply rebooting an instance via regular unix commands over SSH.

Now that the instance has an IP you can setup a domain name with it if you want. The easiest way I’ve found of doing this is through a DNS service like EveryDNS. Just provide your domain name registrar with EveryDNS’s domain name servers, create an EveryDNS account, add your domain and create an A record with your newly associated EC2 instance IP address.

EveryDNS - Setup Domain

The TTL on EveryDNS seems to be fixed at 3600 so it might take a while for propagation, especially if you’re used to pushing down TTL to 300 when doing DNS work.

Terminating Your EC2 Instance

Killing your instance for good can be done, like every other action, through an EC2 command line tool. This time, it’s the appropriately named ec2-terminate-instances (ec2kill). Just provide it with the instance ID of your instance (get it from running ec2din).


ec2-terminate-instances i-yourinstance

Terminate EC2 Instance

It should return with a “shutting-down” status but you’ll definitely want to check back in a few minutes with ec2-describe-instances to make sure it shutdown successfully and comes up as “terminated”. There are a few cases where instances will hang on shutdown and you will continue to be charged for instance hours.

EC2 Instances Terminated

The Next Step

Now that you’ve successfully launched your first Amazon EC2 instance, you’re ready to begin exploring the endless EC2 possibilities. I’m still learning about taking the next step but overall, EC2 really isn’t something to mess with unless you have quite a bit of sysadmin and development experience. Actually using EC2 as an elastic compute cloud usually involves setting up an instance as a load balancer and giving that instance access to an array of active EC2 instances which it can hand work to. Other hurdles include providing multiple instances access to the same database, using Amazon S3 as a persistent filesystem and employing highly redundant backup systems given the relatively volatile nature of instances.

Thoughts? Do you have anything you’d like to use with Amazon EC2?

This post brought to you by a rainy day, a MacBook Air and a Corona.

Paul Stamatiou runs on the Genesis Theme Framework

Genesis Theme Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go.

Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your Genesis site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

85 comments … read them below or add one

  1. Shawn Farner says:

    I think my brain just exploded.

  2. Dimitry says:

    Sick man. No need for this now, but I know where to come when the need arises!

  3. Alex Palma says:

    In English please, LOL but seriously that is a crazy description but very nicely done, I really wish I knew what it was all about ;)

  4. Whoosh! Right over my head, but it created an appealing breeze.

  5. Emil Swenson says:

    Great how-to, Paul!

    By the way,

    “If an instance crashes and you run it again, you’ll loose data and when the instance” <— loose = lose

  6. Evan says:

    Bravo Paul, nice article! Though, I’ll go over this again, in smaller chunks…

  7. Arthur says:

    I’ve recently tried EC2 too, but just played around with it for a day – it would be too expensive for a small website.
    A small instance would cost 0.10*24*31 = ~$75 just for running (backups, traffic, etc. not included).

    Amazon provides a nice calculator:
    http://calculator.s3.amazonaws.com/calc5.html

  8. Tim Trueman says:

    So one thing I’m a little unclear on is the instance hours…is that actual CPU usage, or just time your instance is running?

    P.S. THANK YOU for writing something on this, I haven’t been able to find a nice article on actual EC2 experiences.

    P.P.S. Nice background image

  9. Piku says:

    @Tim Trueman:
    Instance hours is the time the instance is running, not the actual CPU time usage.

  10. Mafuf says:

    It’s sunday morning here Paul….. Sunday is the day when people try to rest their brain and relax a bit, why couldn’t you of done a simple Air update or something equally easy….

  11. Rahul says:

    I’d rather ask my techie-friends to do this for me.

  12. John Willis says:

    Great article.

    btw… We have started an AWSome group (AWS Meetup) in Atlanta. You should check it out. Also if you are interestde you could give a pitch (like this blog entry) at our first meeting. Here are some lings…

    AWSome Atlanta (Cloud Computing User’s Group)

  13. Tom Gleeson says:

    Two useful tools to know about to help make managing EC2 instances much easier, one is a Firefox extension and the other a paid service (but with a free account for developers).

    First the Firefox extension..

    http://developer.amazonwebservices.com/connect/entry.jspa?externalID=609

    ..and then the RightScale service …

    http://www.rightscale.com

    Tom

  14. skipc says:

    well written and illustrated. looking forward to a time when all my personal computing requirements are met online. (then i will be kewl enough to have a MacBook Air). best…skip

  15. Paul,

    If a user donates ($20) or just emails me their username (heh) they can adjust their TTLs. :-)

    -David

  16. Good to know David. EveryDNS is definitely worth donating to.. friends that use it have never had any DNS downtime.

  17. Stefan Neubig says:

    This is what I was looking for. Very nice introduction. Thanks alot. Greetings from Germany

  18. ryanK says:

    After signing up and receiving your EC2 credentials goto Cohesive Flexible Technologies Elastic Server On-Demand.

    You can select a custom list of software components, specify your target deployment (in this case Amazon’s EC2 AMI), build, and auto-deploy to the cloud for free.

    All you need is the FireFox EC2 UI mentioned by Tom above and Elastic Server On-Demand and you can do all the steps above without typing a single command.

  19. David Moore says:

    Could this be used to send video files to for encoding?

  20. @David – absolutely. It’s advertised as both a scalable platform as well as one for offloading batch processing that would require resources you don’t have easy access to.

  21. Nicholas Samson says:

    Nice writeup. I got tired of messing around with EC2 and found Slicehost. Pretty similar service, decent price and much easier to get going.

  22. Adrian says:

    Nice one Paul – this is a great guide!

    Btw – you post this and EC2 was offline for an hour today… just how many readers do you have exactly? ;)

    EC2 has been “stammied”.

  23. Filip says:

    Excellent, excellent post!
    I’m using EC2 myself and I have to say your description of the service is just perfect and comprehensive.

    Good stuff :)

  24. David Moore says:

    i take it the video encoding would need to be done via command line though?

    I mean is there no way of having a GUI OS Install on this thing and you can install a app to Q a load of files up to encode in batch?

  25. David Moore says:
  26. Wow! That is a great detailed set of instructions. I’m definitely bookmarking this on delicious. How is everybody’s success rate with this?

    Just remember, EC2 might not be for everyone. [begin shameless plug] We just launched a new product into public beta called GoGrid which those of you who want true root access (on linux) or admin access (on windows) might be interested in. You can deploy servers in under 5 minutes and even load balance them for free.[end shameless plug]

    EC2 is a pretty amazing bit of technology, especially with the release of elastic IPs and availability zones. But be sure you look “beyond the clouds”.

    -Michael

  27. Sam Jones says:

    Wonderful post! Thank you for this, someday none of us will need our own servers anymore, things will just scale easily with us.

  28. Eric Hammond says:

    Thanks for writing this. The word about this article is spreading around Twitter :)

    I’m curious as to why you picked Gentoo for EC2? I’ve been a fan of Ubuntu for a while and it seems the following is growing. Here’s an Ubuntu 7.10 Gutsy base install AMI for EC2 for those who are interested

    http://ec2gutsy.notlong.com

    Full disclosure: I maintain a series of Ubuntu AMIs as a community service and you can join an Ubuntu on EC2 community here:

    http://groups.google.com/group/ec2ubuntu

  29. “download them to your desktop so you don’t loose them.” keep ‘em tight, all right!

    ahem. Loose != lose. no matter how many people spell it wrong.

    agree with the over the head + breeze comments above.

  30. Man I’d love to get this running w/ Final Cut’s Qmaster. Rendering video on a laptop is the suck.

  31. Tim says:

    Nice Post Paul,

    @ Adrian: ha ha ha!

    I wonder if this could be used to host a game server?

  32. Tj says:

    Thanks for the great post!

  33. Brandon says:

    Amazing post…

    One thing that I would note is that when you terminate an instance that you have allocated an IP address to… you will be billed 1 cent for every hour that the IP address is not associated with an instance.

    To release an address from your account if you don’t plan on using it again or you just don’t want to be billed, type in this command:

    ec2-release-address xx.xxx.xxx.xxx

    more info here:

    http://developer.amazonwebservices.com/connect/entry.jspa?externalID=1346

  34. @Brandon – thanks for the heads up about releasing the IP address, good to know

  35. Nice work, great post.

  36. You have a typo in your description of terminating instances:

    It should return with a “shutting-down” status but you’ll definitely want to check back in a few minutes with >>>ec2-describe-images<<< to make sure it shutdown successfully and comes up as “terminated”

    Should read ‘ec2describe-instances’

  37. Hid S says:

    I’ve just created a EC2 guide for Windows user here http://arope99.blogspot.com/2008/05/getting-started-with-amazon-elastic.html

    Feel free to try it out….

  38. this is also a good guide…
    you should check it out

    http://www.robertsosinski.com/2008/01/26/starting-amazon-ec2-with-mac-os-x/

  39. Adnan Hassan says:

    Hi
    Thanks for a useful post ! i need to know one thing
    using the below command we allow the port 22 to our image i.e modify the firewall..
    PROMPT>ec2-authorize default -p 22

    My question is:
    how can we check the list of ports opened so far at our image or instance ?

  40. ts says:

    Here is another flash based tutorial on Amazon EC2 – http://www.searchblox.com/tutorial/sb_amazon_demo/sb_amazon_demo.htm

  41. Enrico says:

    very nice article and “Terminating an instance seems to be a nuclear option compared to simply rebooting an instance via regular unix commands over SSH.” is gold :-)

    @brandon thanks for the heads up!

  42. thanks! was a great kick start intro.

  43. Don says:

    Thanks Paul

    I was bogged down with the O Reilly Programming AWS book and your writeup is very lucid. Enabled me to get up and running quickly.

    @Brandon

    BIG thanks for the tip about the static IP needing to be released.

  44. Daniel Yokomizo says:

    Great tutorial man, thanks for it.

  45. Nice detailed article on using EC2. It will surely help me setting up EC2 service I’m purchasing next week for my client.

  46. Daniel Liu says:

    Thanks for the awesome write up. Yea.. that sudo part killed me for the longest time.

  47. Paul,

    I wanted to let you know that I referenced your “How to get started with Amazon EC2″ post today on my Technical Manager blog. I wrote about Cloud Computing Examples and referenced you and a couple of your posts. I recently found your blog and enjoy reading about live in the Cloud.

    Thanks – Kevin Mullins

  48. matelko says:

    Hello,

    I’m just wondering how it is with a outgoing ports from AMI instance? Are they all blocked be default. What If I want to enable all ports? I have found another howto and they also talk only about port 22:

    http://www.linuxconfig.org/Howto_CREATE_BUNDLE_UPLOAD_and_ACCESS_custom_Debian_AMI_using_ubuntu

    thanks

  49. @Kevin Mullins – thanks for the coverage!

  50. Anp says:

    Hi,

    A few weeks back I setup ec2 server and now I set up a new one. But how can I get the instance I am running for old one.?>
    whenever I issue the command ec2-describe-instances
    I get the details for the new server I setup.
    How can I get the details for the old one.

    Thanks,
    Anp

  51. mosab says:

    Hi,
    First of all thank you for this wonderfull tutorial, it really was a very good help, when i was lost searching for some.

    I have a small problem.
    i couldn’t find the “id_rsa-pstam-keypair” file and so i am unable to connect to the server, it gives me a “Permission denied (publickey,gssapi-with-mic).” erorr when trying to connect.

    when is this file generated? and where is it supposed to be saved? and how can i regenerate it if possible?!

    thanks in advance, and really good work.

  52. Sergej Losev says:

    thanks, you helped me a lot. Does anybody know of a good ec2 gui client for mac os x?

  53. krunal says:

    Great work..Appreciate your time. Helped me to resolve Issues I was facing.
    Thanks a lot

  54. viraj says:

    Thank You. That was very helpful. Thanks a lot.

  55. Gernot says:

    Thanks for the guide. I’m just getting started w/ EC2 and this was just the ticket.

  56. Parag Shah says:

    Thanks for the post. I wanted to understand why we need both an x.509 certificate and a key pair for working with EC2.

    Your post answered my questions.

  57. Jeebus… That was an excellent tutorial. I would’ve gotten on this EC2 gravy-train months ago if I knew it wasn’t that daunting. Many thanks!

    Btw… I did this on an XP box within 15 minutes. I’d rather be doing this on a mac but it was a rainy day and I stuck with an old laptop. I was SURPRISED it was that easy.

  58. Don Ho says:

    Just wanted to thank you.. this tutorial got me exactly where I wanted to go with no cruft. Many thanks, extremely useful.

  59. Thanks for the very helpful images/article! When my brain stops spinning, I’ll give it a shot. :)

  60. This is exactly what I have been looking for – a comprehensive guide to using the Amazon Cloud. Thanks!

  61. building says:

    Many thanks. It’s posts like these that make the world a better place.

  62. Thx for the info !!! It worked perfectly for me !!! Great article…

  63. Denis Papathanasiou says:

    Thanks for writing this; I found it very helpful.

    FWIW, here’s an important note for anyone using a debian or ubuntu client to run the EC2 command line tools:

    I discovered that you need to use Sun’s JRE (either downloaded and installed from java.sun.com or by specifying the Sun version in apt-get) and use that in the $JAVA_HOME definition, because the gnu “default-jre” package that comes with debian/ubuntu won’t work (discussion and more details here).

  64. Arun says:

    Thanks alot …wonderful post.!!

  65. James Lewis says:

    This kind of article is really useful, Amazon’s documentation seems to start at a little to high a level. What I really need to understand is how to build an AMI, and how to get it uploaded, anyone know an article detailing that process?…

  66. chetanM says:

    Cool very useful to me thanks folks

  67. Chase says:

    hey guys

    very interesting post on private data could.
    http://bigdatamatters.com/bigdatamatters/2009/09/private-cloud-eucalyptus.html

  68. Antoine says:

    Great article to get started !
    But I wish I knew about the AWS management console sooner
    https://console.aws.amazon.com/ec2/
    it’s even easier than this easy walkthrough

  69. Abhimanyu says:

    Here is another article I wrote up in case people are interested. In my opinion it is the fastest and easiest way to get up and running.

    Connecting to Amazon Ec2 Cloud- Quick & Easy

  70. StationStops says:

    Ahh…great tutorial that went problem-free and just opened my eyes a bit – had long conversations today with Amazon and partners about completely dissolving our racks into the cloud…

    Its soooo tempting.

  71. Ken Thomas says:

    StationStops–

    It is not only SOO… tempting… it’s often a great idea (no, I don’t work for AWS). Being able to make an instant image (backup) of an instance solves the backup issue… you can always scale to new hardware (instance size); now, with “stop instances,” you can bid on the computing you need, often reducing the cost by 40-50+%.

  72. David Morton says:

    FYI, for the masses that have been pounding their heads against the wall…

    You can get pk-xxxxx and cert-xxxxx .pem files at:

    https://aws-portal.amazon.com/gp/aws/developer/account/index.html

    this is *NOT* the same as the AWS Management Console.

    the file pk-xxxxx file that you get from the AWS Management Console is the one that you would use to ssh into the instance:

    ssh -i xxxxdownloaded_from_AWS_Management_Consolexxxx.pem root@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com

    This has been a massively painful stumbling block for someone unfamiliar with .pem files.

  73. Dear all,

    I am having a difficult problem with Amazon EC2 and our database.

    We would like to redimension the partition of the virtual Operating System from 4GB to 10GB at least without losing all our data/scripts. At the moment our 4GB is not sufficient.

    Another option it seems to be using a HD Virtual (EBS* – elastic block store) of 10GB as an instance of our previously installed Operating System.

    A final option we believe would be to have a AMI with 10GB OS space + 10GB for storage.

    We need help with a step-by-step guide for beginners in getting a solution set up urgently so we can have our server up and running, this is absolutely critical as the site is just waiting for this to be able to be launched. I have already tried posting in the Amazon forum but obtained no reply and cant find a contact number: http://developer.amazonwebservices.com/connect/thread.jspa?threadID=44927

    Your help is much appreciated, if possible please reply to: bookess@gmail.com

    Kind regards

    Bernardo Carvalho
    Bookess

  74. Ken Thomas says:

    It is relatively easy to resize the partition: just google…

    http://www.marcvalk.net/2010/01/increasing-your-aws-ec2-root-partition-windows/ for instance

  75. Dale Hubbard says:

    Many thanks for this. Looking at EC2 for a BOINC implementation.

  76. Ped says:

    I’d make a small change to the guide. To make the ec2 commandes available from anywhere, (so you don’t have to cd into the .ec2 folder everytime) you just make these modofications to the bash_profile part

    export EC2_HOME=~/.ec2
    export PATH=$PATH:$EC2_HOME/bin
    export EC2_PRIVATE_KEY=~/.ec2/pk-KEYFILE.pem
    export EC2_CERT=~/.ec2/cert-CERTFILE.pem
    export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/

  77. “The commands below assume you are working on an OS X machine in the Terminal.” #epicfail

  78. Rajat says:

    Thanks, this is the most useful and complete EC2 tutorial i have ever seen.

  79. Peter valentine says:

    I must be the stupidest person on the planet but I don’t get the whole concept. It seems you need a real computer on which to display/execute the “virtual” computer so where is the hardware saving in that? Or are you saying that you can use (for example) an image of a giant powerful supercomputer on just an old 386 laptop?
    And if all these virtual computers are loaded with just the software you need, does that somehow eliminate the per-user or per-seat licensing fees for that software? If not — where’s the saving? (told you I was stupid.).
    Peter.

    • Dear Peter,

      Thanks for your comment and question. Simply not knowing yet, is not stupid! as we all start somewhere.

      It’s a little hard though, to address all your concerns. Amazon’s technology is fairly complex.

      Yes, it takes actual hardware. To keep it short, Amazon has “clusters,” as they are called, of very powerful machines, configured correctly to allow “virtual” instances of machines and operating systems to run on them– much as you might run a wordprocessor on your desktop or laptop.

      Yes, you can access these remotely from “any old machine” such as a 386. Just for instance, in fact, you can use a cheap $75 laptop, with a ATOM processor but a large screen, to display the “virtual desktop” of a powerful, (virtual equivalent of) 10 processor, 64-bit architecture machine.

      Amazon must pay licensing fees where applicable. But they only pay for usage, and they likely have a “volume discount.” What this means for you the end-user, is that if you only need a powerful machine for 5 hours/day, you can “fire it up” (request it turned on) for those 5 hours, and pay only 30 cents/hour or so, or about $1.50-$2.00US/day. And you don’t have to pay in advance.

      In my case, I keep a disk image of a Windows 2008 server stored on Amazon. Depending on how much power I need, I can turn this ‘machine’ on from anywhere in the world with an internet connection, “on demand,” and pay between $.10/min and $.50/min, for either a relatively powerful remote “computing instance” with the equivalent 5 processors, or a truly powerful machines.

      Then I “turn it off” and store it, and while it’s off, it’s still there but I am charged nothing (except a few hundreds of a cent for the disk space). Pretty good deal, huh?

      Again, all of this does run somewhere. All you really need to know to start, is that Amazon has an architecture of “really big machines” somewhere, that can run the virtual equivalent of what you’d run on a personal computer, as a walled-off “process” amid many other processes– one powerful machine, you might think of it as, running tens or hundreds of other machines “virtually.”

      I hope this helps explain. Feel free to ask questions– it’s the only way we learn anything!

      Yours,

      Ken Thomas

  80. Shrey says:

    Hello,
    I have installed lamp on my ec2 by using “sudo tasksel install lamp-server” command but as there are some issues of “Deprecated: Assigning” in php5.3.x so i want to uninstall the lamp and re install the older one how should i do that please help i am new bee for ec2 amazon sever.

    Thanks

  81. Shabeer Naha says:

    Then I “turn it off” and store it, and while it’s off, it’s still there but I am charged nothing (except a few hundreds of a cent for the disk space). Pretty good deal, huh?

    Why would one want to turn it off, if running a website ?
    So if theres 0 traffic for 3 days but the instance was on (which has to be 24/7) I still get billed for it being on for those 3 days ?

37 Trackbacks

  1. [...] Getting Started with Amazon EC2 (tags: amazon ec2 hosting howto) [...]

  2. [...] test 04/07/2008 How To: Getting Started with Amazon EC2 – PaulStamatiou.com [...]

  3. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: amazon ec2 tutorial) « links for 2008-04-07 [...]

  4. [...] by Michael on April 8, 2008 Read a HowTo getting started with Amazon’s EC2 here, another interesting article about [...]

  5. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: ec2 amazon howto tutorial hosting server webservices) [...]

  6. [...] Paul Stamatiou: How To: Getting Started with Amazon EC2 (tags: tutorial s3) [...]

  7. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com [...]

  8. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: amazon ec2 tutorial reference tbr) [...]

  9. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com Someday we won’t have to run servers anymore. (tags: ec2) [...]

  10. [...] How To: Getting Started with Amazon EC2 Amazon EC2 is among the more potent items in Amazon’s web services arsenal. You’ve probably heard of many of the other services such as S3 for storage and FPS for payments. EC2 is all about the elastic compute cloud. (tags: amazon development distributed hosting osx server tutorial webdev) [...]

  11. [...] Another Getting Started with EC2 guide for Mac OS X users [...]

  12. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: amazon ec2) April 10th 2008 Posted to Links [...]

  13. [...] you’re interested in testing EC2, I’d recommend this article at paulstamatiou.com to help you get started. Tags: amazon, ec2, lamp, redundancy, scalability, server, [...]

  14. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com “Just because you will be able to host a page on EC2 at the end of this article does not mean you should start using it as your only server. WeoCeo, Scalr and RightScale. Enough talk, shall we jump right in?” (tags: via ec2 popular howto hosting linux) [...]

  15. [...] now, thanks to Amazon EC2 and S3, I type a few commands on my laptop, and somewhere in Seattle a powerful server jumps to life one [...]

  16. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: ec2 amazon howto tutorial aws hosting server webservices) [...]

  17. [...] a Weave-friendly distro with user authenticated WebDAV over HTTPS, I’d love to use it as an Amazon EC2 image. It probably wouldn’t be too hard to setup an EC2 Weave server and sell out spots to users [...]

  18. [...] How To: Getting Started with Amazon EC2 Another good getting started guide about Amazon EC2. Given good detail about creating & starting AMI. [...]

  19. [...] How To: Getting Started with Amazon EC2 Another good getting started guide about Amazon EC2. Given good detail about creating & starting AMI. [...]

  20. [...] How To: Getting Started with Amazon EC2 – PaulStamatiou.com (tags: amazon ec2 webservices) [...]

  21. Amazon EC2 Documentation…

    Get the uptodate complete set of documentation files Go to…

  22. [...] is Amazon’s “computing in the cloud” infrastructure. Curious, I found this Getting Started page that documents how to bring up a machine in the cloud. It’s a bit like rocket [...]

  23. [...] the Railo image after a collegue (you know who you are) spoke highly about Railo. I found a really good tutorial on setting up EC2 so it only took me an hour or so to get up and running. It was surprisingly easy [...]

  24. [...] to How To: Getting Started with Amazon EC2 – PaulStamatiou.com, the following services are built on top of EC2 (and thereby perhaps make scaling up EC2 [...]

  25. [...] a great tutorial on getting an EC2 instance up and running, I had a publicly accessible website and the developer version of Railo running in about 20 [...]

  26. [...] how easy it was to get up and running and the task was simplified greatly for me by an excellent overview by Paul [...]

  27. [...] . Amazon Ec2 Startup Guide 2. Another Amazon Ec2 Startup Guide 3. Systemetic Guide for Amazon EC2 (Over Ten [...]

  28. [...] How To: Getting Started with Amazon EC2 — PaulStamatiou.com [...]

  29. [...] How To: Getting Started with Amazon EC2 | PaulStamatiou.com ec2-describe-images -o amazon (tags: amazon aws ec2 reference) [...]

  30. [...] How To: Getting Started with Amazon EC2 – Good first guide if you don’t know where to start. [...]

  31. Access Amazon AWS…

    Overview Amazon Web Services is a service from Amazon which provides the following tools that we’re using for BB Shield developers: S3 Simple, scalable,……

  32. [...] How To: Getting Started with Amazon EC2 — PaulStamatiou.com (tags: ec2 amazon aws) [...]

  33. [...] the rest here: How To: Getting Started with Amazon EC2 — PaulStamatiou.com This entry was posted on Sunday, April 6th, 2008 at 1:08 am and is filed under news. You can [...]

Leave a Comment

*

Leaving so soon?

Don't forget to check out the Reviews and How-Tos, or read a random post.