Your First EC2 Cloud Computing Session Jan 2013 Ross Whetten, North Carolina State University BIT815 notes 1. After you set up your AWS account, and you receive the confirmation email from Amazon Web Services confirming that your account is active, you can go to the AWS homepage at http://aws.amazon.com and click on the drop-down menu My Account/ Console to access the AWS Management Console webpage. 2. Enter the email address that you used to create your AWS account, select the button next to I am a returning user and my password is:, enter your password in the password box, and click the Sign in using our secure server button. This will take you to the AWS Management Console page. Click on the EC2 symbol to access the Elastic Compute Cloud service.
3. To use EC2, you have to launch an instance of a virtual machine image. Click on the Launch Instance button in the pale yellow box to start this process. This will take you to a page where the default is Classic Wizard, but you have choices of Quick Launch Wizard or AWS Marketplace. We will use the Classic Wizard, so just click the Continue button at the bottom right corner of the window. 4. You should now be at the Request Instances window. Click on the Community AMIs button and wait for the page to load a list of available Amazon Machine Images, or AMIs. These are configured packages consisting of an operating system and other software that have been assembled by members of the computing community and made available for public use through Amazon Web Services. 5. Type cloudbiolinux into the Search window to find AMIs that include this keyword in the description. Cloudbiolinux is a project to make bioinformatics computing resources available on EC2 and other cloud computing environments see http://www.cloudbiolinux.org for more information.
6. Click the Select button at the right end of the line for Ubuntu 12.10 20121224 we may use other AMIs during the course, but this will be fine for your first session. This should take you to the window shown below, where you can choose the type of instance you want to launch. The default instance type is t1.micro, with 1 processor and 613 Mb of RAM. This is fine for practicing Linux command line tools and very simple analyses, but for most of our computing exercises, you will need a more powerful computing platform. Click on the dropdown menu in the Instance Type box to see a list of the available instance types and the resources available in each type. For your first EC2 session, choose the t1.micro instance type, and click the Continue button at the bottom of the window. 7. This should take you to a window with Advanced Instance Options choices of Kernel ID, RAM disk ID, Monitoring, User Data, and IAM role. You need not change any of these from the default settings simply click the Continue button at the bottom of the window to proceed to the next step. 8. The next window is Storage Device Configuration this allows configuration of long-term or shortterm disk storage alternatives, but you need not change these. Click Continue to move on.
9. The next window allows you to name the instance you are starting. This is convenient, because there can be multiple instances running on the same account at the same time, and this name is the easiest way to tell the instances apart. You can name the instance with the identity of the person who started it, or with a description of what the instance is intended to do. Click Continue after typing a name or description in the Value field. 10. The next window allows you to create a key pair, which is a means of allowing you secure access to the computing resources of EC2 and preventing others from unauthorized use of your account at your expense. A key pair consists of a private key and a public key the public key is imported into the virtual machine instance that you will soon launch, and only those users who provide the matching private key will be allowed to log in and use that instance. Enter a name for the key pair in Line 1, then click the Create and Download your Key Pair button in Line 2. A dialog window will open and ask if you want to open or save a file with the name you gave in Line 1 and the extension.pem. Save this file somewhere safe this is the private key, and so it should be kept secure in order to prevent others from accessing your EC2 account. After you have saved the private key file, click Continue to move on. 11. The next page allows configuration of a firewall for the new instance. New rules need to be added to allow SSH connections to port 22, and http connections to port 80 the http connections will be used to display help files that are stored on the instance as HTML documents. To add new rules,
click the Create a new Security Group button, then go to the drop-down menu next to Create a new rule and choose SSH (left). The Port window will show 22, and the Source window will show 0.0.0.0 this is fine. To add a second rule for HTTP access, go to the drop-down menu again and choose HTTP (right). Type a Group Name and Group Description in the appropriate boxes (red circle). Click Continue to move on. 12. The next window is the final step, at which you review all the choices of AMI, storage configuration, key pair, and security group before actually launching the instance. You can edit any of the parameters if desired; when you are ready to launch the instance, click the Launch button.
13. This will take you to a window that reports Your instances are now launching. You can click the Close button to close this window and return to the EC2 Management Console page. If you click the Refresh symbol (a circular arrow at the upper right corner of the web page), the Management Console will update the status of resources you are using, and it should now show a running instance in the My Resources section in the upper right corner of the screen. 14. Click on the 1 Running Instance link to go to the EC2 Dashboard page, which shows information on all your EC2 resources. You should see a line with information about the instance that you launched when the launch process is complete, clicking on the checkbox next to that instance line will show all the details of the instance configuration, as shown in the figure on the next page. The key piece of information on this page is the Public DNS address circled in red on the figure the address provided for your instance will be the address you use to log in to your virtual machine instance.
15. You will use a tool called SSH ( secure shell ) to log in to your instance. If you use a Mac, this should be available through Terminal. If you use Windows, you must download a package of programs from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. Choose the zip archive containing all programs, under the Binaries section of the web page. This archive can be unpacked to a folder called Putty anywhere on your computer; the programs do not need to be installed by a Windows installer. 16. Open the Putty folder and double-click the PUTTYGEN.EXE file to start the PuttyGen program. This can convert the private key (SomeName.pem) file you downloaded from AWS into a form usable by the Putty program, which will allow you to make an SSH connection with your EC2 instance. When PuttyGen opens, click the Load button to open a file-open dialog window. In the file-open dialog window, choose All files from the drop-down menu (see blue circle, lower figure) rather than Putty Private Key files (*.ppk), which is the default choice. After choosing All files, browse to the location where you saved the SomeName.pem file downloaded from EC2, select that file, and click Load. This will load the.pem file into PuttyGen, and alert you that the key file must be saved as a.ppk format key file in order to use it with Putty. Click OK in the PuttyGen Notice window, and the Save Public Key and Save Private Key buttons at the bottom of the PuttyGen window will become active. You can then click the Save Private Key button and browse to the location where you would like to save the private key file. You have the option of creating a passphrase for the private key file this provides an
additional level of security, because this passphrase will have to be entered each time the private key is used, so even if your private key file is copied, it cannot be used to access your EC2 instances unless the copier knows the passphrase. If you choose to save the private key without entering a passphrase, the program will ask if you are sure you want to do that you can click Yes to proceed to the next step. Running PuTTY to connect to an EC2 instance Double-click the PUTTY.EXE icon in the Putty folder to start the Putty program. Scroll down in the left-side tree structure to the SSH heading (red circle) if there is a + next to the Connection heading, click that to open the tree to show the SSH heading. Click the + next to SSH to open the tree, and select Auth. On the right side, look under the Authentication parameters heading, and click the Browse button next to the window marked Load a private key file for authentication (blue circle). Navigate to the location where the PUTTYGEN-modified key file is saved, and load that modified key. On the left side tree-structure, go back to the Session heading, type a name in the Saved Sessions box (green circle) and click save to save the SSH configuration. Each time you load this saved session, you will be connecting to a different IP address provided by AWS, so the IP address window can be empty or contain a reminder about inserting the appropriate address. To use your saved session, you can click on the name of the session in the Saved Sessions window, then click the Load button. Go back to the EC2 Dashboard web page and copy the Public DNS address of your instance, and paste that address into the Host Name (or IP address) box in the Putty window, then click the Open button at the
bottom of the screen. This will open a terminal window on your screen, in which you will interact with the Linux computer that is running as a virtual machine instance on the EC2 cloud. The first time you log in to a new instance, Putty will alert you that the identity of that remote machine cannot be verified because it is not stored in the list of remote machines that you have used in the past. This is to be expected each instance is a new machine, in effect and so you can click Yes to continue connecting to the EC2 instance. After you click Yes on the Security Alert window, you should see a terminal window with a login prompt. The default username for all Ubuntu instances is ubuntu (not capitalized), and this user is allowed to log in without a password if the private key supplied by Putty during the login process matches the public key saved on the instance from your account by EC2 as the instance was launched. 17. THE MOST IMPORTANT PART: You must terminate the instance when you are finished, or AWS will continue to charge you for the time that the instance is running. To terminate an instance, first type logout at the prompt in the terminal window. The terminal will close, because you have ended the login session, but the instance is still running, and you will continue to be charged. In order to terminate the instance so that you will not be charged for additional run time, you must return to the EC2 Dashboard web page. You may have to log in to the AWS console web page again if the instance has been running more than an hour or so, because AWS automatically logs users out if no action is taken on the web page in a certain time. After you login and go to the EC2 Dashboard, click on the Actions button and select Terminate from the list. A window will open, asking if you are sure you want to terminate the instance click the Terminate This Instance button. The EC2 Dashboard will list the instance state as terminated when the process is complete now you can log out of the AWS site knowing that you will not be charged for additional time.