1. AWS Login
Log in to your Amazon Web Services account, using the “My Account” menu option and choosing the “AWS Management Console” link (as shown below).
The AWS management console page will look something like below;
2. Elastic Cloud Compute (EC2)
Click on the “Services” option in the top menu bar and then click “EC2” under the “Compute” group, to go to the EC2 management console.
2.1. EC2 menu options
The EC2 console has a left hand side menu bar that has options grouped under “Instances”, “Images”, “Elastic Block Store” etc. By default the EC2 console displays the “EC2 Dashboard” menu option.
The above screenshot shows that there are no running instances, no volumes, no elastic ips, 10 key paris, 1 snapshots etc. This is the summary of all the existing EC2 related resources in this account. Clicking on any of those (for example… “10 Key Pairs” will take you to that section of the EC2 console).
2.2. Creating an on-demand Instance
2.2.1. Click on the “Instances” menu option, from the left hand side menu. The instances window provides information about all your created instances. Currently there are no instances created in this account.
2.2.2. Click on the “Launch Instance” button. This will open up a workflow with 7 steps. The very first step is to choose an AMI (Amazon Machine Image).
2.2.3. Scroll through the list on the right hand side, until you see “Ubuntu Server 16.06 LTS…”. We are going to select (Click “Select” button) this Ubuntu linux server operating system image, to create an instance of it running in the AWS.
2.2.4. After the AMI is selected, we need choose the instance type in Step 2. Scroll through the list and click on the little left hand side box to choose the instance type (in the below example we are choosing the “t2.micro” instance type - the selection is shown as a blue filled box).
2.2.5. Once the instance type is selected, click the “Review and Launch” button at the bottom of that page (shown in the above screenshot). Scroll through the page, make sure you have the correct AMI and instance type. Click the “Launch” button at the bottom of the Step 7: Review Instance Launch page.
2.3. Setting the Key Pair
Clicking the “Launch” button will bring up the key pair creation/selection window.
Make sure you have the “Create a new key pair” option selected.
Provide a meaningful keypair name.
Click the “Download Key Pair” button, to save a key file in a secure location.
Click the “Launch Instances” button, to launch your instance of Ubuntu in AWS, as a 1 vCPU and 1 GB RAM machine.
2.4. Instance Information
Click on the instance id shown in the resulting “Launch Status” page, to go to the instance window, in the EC2 console.
2.4.1. The instance window has two main panels.
The top panel (yellow highlighted) provides a list of all instances running, stopped or terminated. Use the horizontal scroll bar in the top panel to look at all the instance related information.
The bottom panel (blue highlighted) provides all information related to a selected instance (selection shown a blue checked box). Use the vertical scroll bar in the bottom panel to look at all the instance related information for a specific instance.
2.4.2. Instance IP address
Select your instance of choice and (with the “Description” tab on), note down your instance IP address (22.214.171.124 in the below screenshot, yours will be different).
2.4.3. Instance storage
Scroll down the bottom panel (with the “Description” tab on) until you see the “Root device” option. This is the device (like a hard drive) where all your software (operating system) is stored. Click on the device name (in the below example it is… /dev/sda1).
2.4.4. In the resulting “Block Device” information window, click the “EBS ID”. This is take you to the “Volumes” menu option.
2.4.5. The Volume menu shows the volume (aka device or hard drive or storage) where the root (aka operating system software) is running from. We can see that it is a 8 GB volume and is with the “In-use” state.
3. Working with an instance
3.1. Connect to an instance (from PC)
There are multiple ways you can connect to your linux instance that is running. We are going to use an SSH client to connect to our t2.micro instance.
You need three things to connect to your instance;
Instance address (ip address)
Instance user name (“ubuntu” for this instance)
Instance key pair file (“nih1.pem” for this instance)
3.1.1. Using Putty in a Windows machine
Search for the program “puttygen” in the windows machine or start puttygen from the putty installation folder. The puttygen icon looks like this;
3.1.2. In the Key Generator windows, click the “Load” button, change the file type to “All Files” and choose the “nih1.pem” file and click “Open”. If everything goes successfully, you will see a putty notice. Click “Ok” to discard that message.
3.1.3. Back in the Key Generator window, click the “Save Private Key” button and save the key with the same name as the original downloaded key (nih1). Say “Yes” to discard the message about key passphrase. Close the Key Generator window after saving the .ppk file.
3.1.4. Start Putty from your putty installation folder or by searching for it in the windows start. The putty icon looks like this;
3.1.5. In the Putty Configuration window, enter your instance IP address for the “Host Name” and make sure “22” is chosen for Port.
3.1.6. In the same Putty Configuration window, click the “SSH” option to expand it and then click “Auth”. In the resulting “Options controlling SSH authentication” window, use the “Browse” button to set the path for the nih1.ppk file.
3.1.7. Click “Open”. This will prompt the “Putty Security Alert”. Press “Yes” to accept the signature of the computer.
3.1.8. When prompted, enter “ubuntu” as the login name:
3.1.9. If you get any errors, close the existing putty window, start a new putty window and try to connect again using steps 3.1.5. to 3.1.8. If successfully connected, you will see the ubuntu shell prompt, which is now ready for you to work.
To get out of the machine (not shutting down, just logging out), just close the putty window.
3.2. Connect to an instance (from Mac)
3.2.1. Start the “Terminal” in your Mac machine. You can find the “Terminal” app in your “Applications” - “Utilities” folder.
3.2.2. You can also type “terminal” in your mac spotlight to find the Terminal application. Click on the Terminal icon to start the terminal.
3.2.3. In your terminal, change to the directory where you downloaded the .pem keypair file. Usually your terminal will start in your home directory. From there, typing “cd Downloads” will change to the Downloads directory (if that is where you have the .pem keypair file). Once you are in the appropriate directory, run the following command (type it in the terminal and hit enter to run it) to change the keypair file mode;
chmod 400 nih1.pem
3.2.4. Once the .pem file mode is changed, you can connect to your instance by running the ssh command as shown below;
ssh -i “nih1.pem” firstname.lastname@example.org
The above command will log you in to your linux instance. If asked, accept the key signature question.
Just close the terminal to log out of your linux instance.
3.2. Stop an instance
Your instance will be charged for compute as long as it is running (if STARTed). If you want to keep your instance - but dont want to pay for the compute charge, you can STOP it, like physically turning it off, and START it at a later time.
To stop a running instance
Go to your EC2 console web page.
Chose the Instances menu option
Check the running instance that you want to stop
Click Actions menu, then “Instance State”, then “Stop”.
If you get any warning messages, ignore them and “Stop” the instance.
3.3. START the stopped instance
The stopped instance is like your physically shutdown computer. You have your computer, but it is powered down and wont be accessible through Putty or SSH terminal. If you want to access it again, you have to START it.
To START a “stopped” instance;
Go to your EC2 console web page.
Chose the Instances menu option
Check the “stopped” instance that you want to start
Click Actions menu, then “Instance State”, then “Start”.
3.4. Terminate the instance
If you do not want your instance or its associated volumes anymore, you can terminate the instance (Actions - Instance State - Terminate menu option as shown in the above screenshot) and delete the associated volumes.
Having an instance in a STOPPED state will only help you save money with compute costs, but you will continue to be charged for the storage (volume) associated with your STOPPED instance.
If you terminate your instance and delete any associated (attached) volumes, everything associated with that instance would be gone forever. If you want an instance again, you would have to start over all again from step #2.