Saturday, April 1, 2017

Creating a Linux EC2 instance and logging into it

Now that we know how to create a Key Pair  and a Security Group, we will create a Linux EC2 instance and then log into it. In the future blogs, we will look into deploying applications in the Linux EC2 instance.

1) First step is to go to the EC2 management console as mentioned in the previous blog. Click on the instances link in the left pane. If you are using AWS for the first time, there shouldn't be any instances as shown below.

2) Click on the `Launch Instance` button and select the AMI. Amazon Machine Image (AMI) is a template for the OS, Applications, Configurations etc. More about the AMI here. There are free and paid versions of the AMI. In fact, it's also possible to create an AMI and share it with others for free or at a cost, which is a topic for another blog. For now, we will select the Amazon Linux AMI.

3) Now, we can select the EC2 instance type. We will pick t2.micro, which is eligible for the free tier. There are a lot of instance types and based on the requirements, we can choose an appropriate one. Here is a deep dive on how to pick the right size of the instance. t2.micro are burstable instances, more here.

4) Click on `Next Configure Instance Details`. The default options should be good enough. But, you can explore the different options. Hover on the i label with a circle to get more information about a particular option.

5) Click on `Next : Add Storage`. Here also the default options are good enough to start with. But, keep exploring the different options. The EC2 AMI which we picked will be attached with a 8GB hard disk. The size of the disk can be increased or more disks can be added. As mentioned leave the option as is.

6) Click on `Next : Add Tags`. Here is where we can categorize the different AWS resources like production/development/testing or accounts/sales/hr. More about tagging here.

7) Click on `Next : Configure Security Group` and select the SG which has been created in the previous blog.

8) Click on `Review and Launch`.

9) Review the details and click on `Launch`.

10) Select the Key Pair which has been created previously and accepting the acknowledgment.

11) Click on `Launch Instances`.

12) Click on `View Instances` at the bottom of the screen.

13) The EC2 will be in a pending state as shown below.

14) After a few seconds, the instance state will change into running as shown below. This means the instance is ready and we should be able to login to the instance now.

15) Note the ec2 ip or the dns name in the same screen.

16) Download putty.exe and launch it. There is no need to install it. Enter the user name and the ip address as shown below.

17) In the putty pane, expand Connection -> SSH -> Auth. Browse to the ppk file which has been created earlier.

 18) Click on `Open`. There will be a putty security alert as shown below. Simply accept it.

19) Now, we should be able to login to the EC2 Linux instance from windows.

20) The best practice is to update the OS with the latest patches. Run the `sudo yum update` command with the quotes. Accept when asked for the confirmation.

21) In the future blogs, we will look into deploying applications on the instance. For now come of the instance by saying exit.

22) The `t2.micro` instance which we create falls under the AWS free tier. Once we are done with the instance, make sure the instance is shut down or else after the AWS free tier it will be charged.

23) Select the instance. Click on Actions -> Instance State -> Terminate.
24) Confirm that you want to terminate.

25) After some time the status of the ec2 instance will become terminated.

Note how easy it is to start a instance in the cloud. Without the cloud, first we have to do the capacity planning, get the approval, send the invoice and procure, get the physical space, cooling, network security, physical security and a lot of other things before we get started with deploying the applications. This is the beauty of the cloud, provisioning instantly.

We can start as many instances as we want and shutdown when we don't need them. This is called elasticity. The good thing is we pay for what we use and nothing more.

In the next blog, we will start a Windows EC2 instance and log into it. Hope you guys are having fun with AWS. There is lot more to it, which we will explore in the upcoming blogs.

1 comment: