0% found this document useful (0 votes)
9 views

CloudWithAWS TIO 1 v1.1

Uploaded by

Salvador
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CloudWithAWS TIO 1 v1.1

Uploaded by

Salvador
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

PGP in Cloud Computing

Try it out objective


Use this hands-on to get started with EC2. You'll learn how to launch, connect to, and use a Linux instance. An instance is a virtual
server/machine (VM) in the AWS Cloud running a specific operating system and can be used to host applications and databases.

The goal

The following are the goals of this hands-on:

1. Understand the process of launching an instance

2. Install a simple http webserver

3. Access the site from a browser

4. Connect to the instance via SSH (optional for non technical learners)

5. Terminate an instance

Please note if a field (short for text field/text area/checkbox/radio/dropdown/list or any other UI element) is not specified in the following steps, it means the
default value of the field set by AWS needs to be used. No change is needed for those fields as part of this hands-on.

Try it out! Page 1 of 7


PGP in Cloud Computing

A. Hands-On: Launch an instance


1. Open the EC2 management console at https://console.aws.amazon.com/ec2/ (you will be required to sign in)

2. Change the region to N Virginia (if it is not already selected). The region dropdown is located at the top right of the EC2 management console.

3. From the EC2 management console, click on Launch Instance (ignore the template option).

4. The Choose an Amazon Machine Image (AMI) page displays a list of basic configurations, called Amazon Machine Images (AMIs), that serve as templates
for your instance. Click on the “Select” button of the HVM version of Amazon Linux 2. This should be the very first option in the list of AMIs displayed on this
screen.

5. On the Choose an Instance Type page, select the t2.micro instance type, which is selected by default. The t2.micro instance type is eligible for the free tier.
Click on the “Next: Configure Instance Details” button on the right bottom of the page.

6. On the Configure instance details page make the following changes -

a) In the Network dropdown, ensure the default vpc is selected

b) Change the Subnet to us-east-1a in the dropdown

c) In the user data field (bottom on the page) paste the following script (installs the http server and creates a home page) -

Important note - please copy the complete script properly. A typical mistake is to not select the first and the last few characters. It is also possible the
spaces in the script can be replaced with special characters which may lead to errors. It is best the script be copied to a pure text editor (Notepad++, GEdit
etc) and then copy from the editor to the user data field.

#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
IP_ADDR=$(curl http://169.254.169.254/latest/meta-data/public-ipv4)
echo "Manual instance with IP $IP_ADDR" > /var/www/html/index.html

Try it out! Page 2 of 7


PGP in Cloud Computing

d) Click on “Next: Add Storage” button (right side bottom of the page)

7. No changes are needed on the Add Storage page. Click on the “Next: Add Tags” button on the right side bottom of the page

8. On the Add Tags page, make the following changes -

a) Click on the link (in the middle of the page) “click to add a Name tag”

b) Ensure the Key field has the text Name already prepopulated (do not change this)

c) In the Value field paste the value as mentioned below

httpserver1

d) Click on “Next: Configure Security Group” button on the right side bottom of the page

9. In the Configure Security Group page, make the following changes -

a) Ensure the radio button Create a new security group is selected (should be already by default)

b) Paste the value of the Security Group Name field from below (remove any existing value from this field)

tio1-sg

c) Paste the value of the Description field from below (remove any existing value from this field)

Opens security groups for ssh and http

d) A rule for SSH is already added, change the Source dropdown to Anywhere

Try it out! Page 3 of 7


PGP in Cloud Computing

e) Click on the Add Rule button to add the second rule for this security group

f) Click the Type dropdown of this row (not the earlier SSH row) and select HTTP, change the Source dropdown to Anywhere

g) Click on Review and Launch button on the right side bottom of the page

10. On the Review Instance Launch page, click the Launch button on the right side bottom of the page.

a) A popup will open when the launch button is clicked

b) When prompted for a key pair, select Choose “Create a new key pair” from the dropdown
c) In the Key pair name field paste the following value

pgpcc-key1

d) Clik on the Download Key Pair button just below the Key pair name field

e) Save the file that is downloaded in a secure directory on your laptop/desktop (remember this location)

f) Click on the Launch button (in the popup)

11. In the Launch Status confirmation page click on the View Instances button on the right side bottom of the page

12. Click on the Checkbox to the left of the httpserver1 displayed in the Instances table

13. The bottom of the screen shows the instance attributes and the Details tab is visible by default (do not change it)

14. Locate the display item “Public IPv4 address” and copy the public IP address (do not click on the open address link, it defaults to https and the page will not
work). Save this public IP address (does not start with 172.31.x.x) in a text editor or write it down on a piece of paper if you wish to do the SSH exercise.

15. Open a new browser tab, paste the public IP address and hit enter. The http page will be visible.

B. Hands-on: SSH to an instance

Try it out! Page 4 of 7


PGP in Cloud Computing

This hands-on is optional for learners who are not from technical background. Proceed to the next hands-on “C” if you intend to skip it.

Important note - please copy each command properly. A typical mistake is to not select the first and the last few characters leading to errors. All commands are
case sensitive and observe the spaces carefully between the command and the respective arguments. It is best to copy/paste these commands.
1. Open a terminal window (steps to install and verify a terminal window is in Olympus) on your laptop/desktop

2. Change the directory to the location where the PEM (or CER or TXT) file was downloaded in the previous exercise

3. Copy and Paste to execute (by hitting enter) the following command in the terminal window -

chmod 400 pgpcc-key1*

4. Copy and Paste the following command in the terminal window. Delete the bold text in the command below and type the public ip instead (refer to the text
editor or piece of paper) of the instance. Execute the command by hitting enter -

ssh -i pgpcc-key1* ec2-user@PUBLICIP

5. Apart from other display, there will be a prompt which may look like this “Are you sure you want to continue connecting (yes/no/[fingerprint])?”. Type in yes
and hit enter

6. Try out the following linux commands (copy paste the commands individually and hit enter after each)

Try it out! Page 5 of 7


PGP in Cloud Computing

ls -al

mkdir test

ls -al

cd /opt

exit

7. Close the terminal window

8. An alternative to SSH is via the “EC2 Instance Connect” option. To use it go back to the browser tab EC2 management console.

9. Click on Instances in the left navigation

10. Click on the Checkbox to the left of the httpserver1 displayed in the Instances table (no action is necessary if the checkbox is already selected)

11. Click on the Connect button towards the top right side of the screen

12. In the new page which shows a few tabs, the default tab will be EC2 Instance Connect

13. Click on the Connect button and a new browser tab (popup may need to be enabled) will show the terminal window

14. Try out the linux commands from the earlier steps (note - creating the directory will fail because it already exists)

C. Hands-On: Terminating/deleting an instance


This exercise is mandatory for all learners.

1. Go back to the browser tab EC2 management console

Try it out! Page 6 of 7


PGP in Cloud Computing

2. Click on Instances in the left navigation

3. Click on the Checkbox to the left of the httpserver1 displayed in the Instances table (no action is necessary if the checkbox is already selected)

4. Click on the Instance state dropdown towards the top right side of the screen

5. Select Terminate instance option

6. Click on the Terminate button on the confirmation popup window

7. The instance will show in Shutting down status and a few moments later will show as Terminated

8. Terminated instances do not attract any costs and will be auto removed from the instance listing in about 2 hours (or less)

Try it out! Page 7 of 7

You might also like