Tuesday, December 13, 2016

(1) Go to https://aws.amazon.com/console/.

(2) Login with:  
peereffects2016@gmail.com
password:  peereffects2016

(3) Go to: https://eu-central-1.console.aws.amazon.com/ec2/v2/home?region=eu-central-1#Images:visibility=private-images;search=ami-57f73638;sort=name

This is where we keep the AMIs  "Amazon Machine Image".  These are snapshots of fully setup server.   This one for example is one I created today based on an old one.    Starting up a server from one of these images takes about 3 minutes.  The image is a snapshot of the operating system together with a hard disk (compressed), and it can be "embodied"  by any hardware.

(a) In "actions" select launch.   You will get a menu with all kinds of hardware configurations. Here is a list of prices:  https://aws.amazon.com/ec2/pricing/on-demand/

I suggest that you use the free ones "t2.micro"  to figure out how everything works.  
For work I have used so far either:

r4.xlarge     $0.266  per hour
r4.2xlarge  $ 0.532 per hour

These are not huge, but they do have 30.5 and 61 Gb of Ram respectively which I have not come close to using.  But as you can see, among the memory optimized ones there are absolutelly crazy things like:
x1.16xlarge with 64 cpus and 976 GB of RAM  and still pretty cheap,  $6.675  an hour.
I don't think that we will ever need something  like that. But knowing that it exists is liberating.

Anyhow!  The credit card is still mine, but hopefully from tomorrow on it will be MOVE's. 

 (b)  Just press "Review and Launch"  (Most details are already configured in the image).

(c) At the top of the page press 6. Configure security group.

(d) Press add rule. And in "Type"  select HTTP  (The default port should be 80).  Select review and  launch  and launch.

(e) Select Create new key pair (this is the only time you need to do it; it is for the SSH stuff).  Give it a name and just save it in some obvious directory in your dropbox.

(f) Launch instance. Press View instances.   You will see that it is being created. It should take maybe 3 minutes.   The reason it takes a while is that it is creating the hard disk etc...

(g) Once it finishes initializing, copy the public DNS to your browser, and you are in Rstudio.  login:rstudio, password: rstudio.

(h) If you want to SSH go to a terminal and type:

ssh -i AW2Key.pem ubuntu@"public DNS"

 Where "AW2Key.pem"is the name of the key that you created in    step (e).  You should do this by standing in the directory in which you created it.  Otherwise use the whole path.

A useful utility that I installed is called  htop,  you can use it to see what the computer is doing, whether it is overtaxed etc....
You can launch the Rserver and R from there.   But in my experience it works perfectly well via the browser interface.

 NOTE:  Dropbox starts automatically and synchronizes with KeyTransfer,    so if you don't see some file wait a bit until it refreshes. 
I will be updating images once in a while so that this is fast.

---------------------------------------------------------------------------
When you are done  go to your Amazon console (which will still be open somewhere in your browser)  and STOP  the machine.  
Stopping is key so that they stop charging us.  

Amazon basically does not charge us for Stopped machines (maybe a very small monthly fee, but not more---.

If a machine is stopped then you can restart it next time  and you don't have to do any of the steps above!
The steps above are to create a whole new machine from the disk image  that I set up.

A more radical step than stopping is Terminating.   Terminating can be good if one is sure that the machine (for instance a huge one) won't be used in a long while.   Anyhow, steps (a)-(d) + ) are  super fast once one has done them a  few times.  


This guy:
 http://www.louisaslett.com/RStudio_AMI/

 has great resources and links to pre-created image.  That is how I created the first version of ours.  But now ours has all the packages that we need in R, our dropbox etc...
But his resources are very useful in general.