Exploring AWS EC2 — Part I

Suganth S
Starter Stuffs
Published in
4 min readSep 15, 2019

AWS EC2 setup under Free Tier

Login to AWS Account. If you do not have account, kindly create account. This will take about 2–3 mins to create account.

Once logged in, you will be redirected to AWS console. Here you can find ‘EC2’ options under All Services -> Compute. Click that. Now you will be in AWS EC2 page. Click ‘Launch Instance’.

Step 1: Choose AMI

First you need to select which type of machine you need. Here you find a list of machines. I prefer Amazon Linux AMI 2018.03.0 (HVM), SSD Volume Type(which is usually 2nd in the list) since Java, PHP, Docker, MySQL and few other application are installed by default. Select the machine.

Step 2: Choose Instance Type

Here you can find the different variant of Types for selected AMI machines. Let’s start with t2.micro(which is under Free tire eligible). Click ‘Next: Configure Instance Details’

Step 3: Configure Instance

Here youcan find various options for our server and control over the server. These will be covered later in detail(upcoming article). For now let’s just click ‘Next: Add Storage’

Step 4: Add Storage

In this step you can add storage to our machine, which is typically the ROM. By default 8 GB is allocated to our machine. Let’s proceed with same to ‘Next: Add Tags’.

Step 5: Add Tags

In this step you can add tags to our machine. To know more checkout the documentation. For now just click Next: Configure Security Group.

Step 6: Configure Security Group

Here you can specify some of the security to our machine. If suppose you are running a service at port 80, you can close connection for other ports from external sources. This can be configured here. By default port 22 will be open through which you can connect to our machine through ssh. Don’t change anything , just ‘Review and Launch’.

Step 7: Launch

Once you get to Launch page , click Launch. You will be opted with a pop-up asking for you to create private key. Let’s create a new key pair and give some name in Key Pair name. I have given ‘sample’. Then click Download Key Pair. A pem file with the same name will be downloaded. This is the private file through which you can ssh to the Machine(mentioned in above step). Now click ‘Launch Instances’.

Once instance is created you will get a success message with instance Id. Click the instance Id. You will be redirected to Instance list page. Wait till the Instance status changes to running and Status Checks becomes 2/2 checks…

You can find the Instance Description below. Here you can find the Public DNS, public IP and few other important data.

Note: Public DNS and IP changes each time when you restart or start the system(after shutdown).

Now EC2 machine is started and running. Free tier provides only 750 hours per month in free Quota. Once usage goes more than that then you need to pay based on usage. Running a machine continuously will not cross over this. You need to worry only when you run 2 or more instances.

Fine. Let’s connect to out EC2 machine through SSH.

My pem file is in Downloads and My machine’s Public IP is 18.221.188.101.(From Description).

The default username for Linux EC2 machines is ‘ec2-user’

ssh -i Downloads/sample.pem ec2-user@18.221.188.101

It will ask for conformation. Type ‘yes

You must be getting bad permissions error. This is because permissions to pem file is open. You have to set permission to the file. Execute the following command.

sudo chmod 600 Downloads/sample.pem

Now try executing the ssh command which you tried before. You must be able to login to AWS.

Checkout next article for deploying a sample Node Js server in EC2 machine.

Feel free to contact me for any queries.

Email: suganth2610@gamil.com

--

--