Lab-6 Ec2 Instance
Lab-6 Ec2 Instance
Lab-6 Ec2 Instance
AIM :
Using account in Amazon AWS, create a virtual machine, connect and work with it.
PROCEDURE :
a. You are now in the Amazon EC2 console. Click Launch Instance
b. With Amazon EC2, you can specify the software and specifications of the instance you
want to use. In this screen, you are shown options to choose an Amazon Machine
Image(AMI), which is a template that contains the software configuration required to launch
your instance.
For this tutorial, find Amazon Linux AMI 2018.03.0 and Click Select.
c. You will now choose an instance type. Instance types comprise of varying combinations of
CPU, memory, storage and networking capacity so you can choose the appropriate mix for
your applications. For more information, see Amazon EC2 Instance Types.
For this tutorial, select the default option of t2.micro-this instance type is covered within the
free tier. Click Review and Launch at the bottom of the page.
You can review the options that are selected for your instance which include AMI
Details, Instance Type, Instance details, Storage, and Tags. You can leave these at the
defaults and move next and launch.
Step 3: Create a security group
AWS security groups (SGs) are associated with EC2 instances and provide security at the protocol
and port access level. Each security group – working much the same way as a firewall – contains a
set of rules that filter traffic coming into and out of an EC2 instance.
Each security group must have a name, allowing you to easily identify it from account menus. It’s
always a good idea to choose a descriptive name that will quickly tell you this group’s purpose. In
fact, you would be well served to define and use a consistent convention for naming all objects in
your AWS account.
Security groups exist within individual VPCs. When you create a new group, make sure that it’s in
the same VPC as the resources it’s meant to protect.
To connect to your virtual machine, you need a key pair. A key pair is used to log into your
Instance (just like your house key is used to enter your home).
a. In the popover, select Create a new key pair and name it Demo. Then click Download Key
Pair. Demo.pem will be downloaded to your computer—make sure to save this key pair in a
safe location on your computer.
Windows Users: We recommend saving key pair in your user directory in a sub dir-
ectory called .ssh (ex.C:\use5r\{yourusername}\.ssh\Demo.pem).
Mac/Linux users: We recommended saving your key pair in the .ssh sub-directory
from your home directory(ex.~/.ssh/Demo.pem).
Note: If you don’t remember where you store your SSH private key (the file you are
downloading), you won’t be able to connect to your virtual machine.
b. After you have downloaded and saved your key pair, click Launch Instance to start your
Amazon Linux AMI server instance.
c. On the next screen, click View instance to view the instance you have just created and see its
status. The screen looks as follow after launching the instance.
After clicking at the instance we can see the Instance state as Pending , After some time the state
changes to Running state where we can start connecting our instance using Putty .
Before connecting to Putty first we need to convert .pem file into .ppk file using the below process
Open Putttygen - > Click File - > Click Load private key which is as follows:
After loading the file it looks as follows. After loading click on Save Private Key.
After launching your instance, it’s time to connect to it using an SSH client using putty.
a. In order to connect to your Amazon virtual machine instance, you will need to use Host
name or public IP of the current running Instance. You can find the public IP of the running
instance in the description section of AWS Console.
We need to give the username the default user name to connect to Amazon Linux AMI Server is
login as : ec2 -user
Here we are trying to make use of the virtual machine instance that is created on AWS
For our for our experiment we are creating a simple web server on ec2 instance and
dumping simple HTML files into that
Now create simple HTML file called index.HTML using simple nano text editor in the
directory /var/www /html/
Inorder to check the output, open a web browser and type the specified URL: public dns of the
launched instance has to be copied from AWS Console and paste it as URL.
You can easily terminate the Linux Server VM from the Amazon EC2 console. In fact, it is a best
practice to terminate instances you are no longer using so you don’t keep getting charged for them
a. Back on EC2 Console, select the box next to the instance you created. Then click the Action
button, navigate to Instance State, and click Terminate.
b. You will be asked to confirm your termination- select Yes, Terminate.
Note: This process can take several seconds to complete. Once your instance has been
terminated, the Instance State will change to terminated on your EC2 Console.
RESULT : You have successfully created, configured, and connected to your first Amazon Linux
Virtual Machine in the cloud with Amazon EC2.