Create a Linux Instance in Amazon EC2

In this post we will create and Amazon Linux Instance from Amazon AMI by using Amazon Management Console.

The obvious question in beginner's mind is what is Amazon EC2? 

In plain simple English, it provides resizable (elastic) compute capacity in Cloud environment. In traditional environment, the biggest challenge is to acquire (provision) resources (in our case it is compute / Server /Virtual Machine / Physical Machine). Pay as you go billing model provides immense flexibility to create compute resources in Public Cloud environment with the use of Amazon EC2.

Go to aws.amazon.com



56.1 Amazon Management Console

 Click on My Account, and select AWS Management Console from the drop down menu.
56.2 Amazon Management Console

 Sign in with AWS credentials.
56.3 Amazon Management Console Sign in

 AWS Management Console, Click on EC2 in Compute Section.
56.4 Amazon Management Console Services

It will open Amazon EC2 Dashboard. Just observe Resources section, you will have only 1 Key Pairs and 1 Security Group if you have created account recently and using it first time. Click on Launch Instance to create a new virtual machine.
56.5 AWS Launch Instance

Step 1 is to choose and AMI - Amazon Machine Image, a template that contains operating system, web or application server, applications, etc. that are required to launch instance. We will select Free Tier Eligible AMI - Amazon Linux AMI. Click on Select.
56.6 AWS Create Instance
In step 2, we need to select Instance type. Don't get confused with terminologies. Instance type is nothing but a type of Virtual Machine. Each Instance is a distinct combination of Type of instance, vCPU, Memory, Storage, Network Performance based on the use cases considered by AWS based on patterns decided by them. We will keep t2. micro and click on "Next: Configure Instance Details"
56.7 AWS Configure Instance Details

In step 3,Configure the instance section provides some very important details. Observe "Number of Instances" parameter :-). In simple terms, it means that we can create multiple instances with same kind of configuration with in quick time. Easy, isn't it?
Some other important information which we will cover later on is Network, IAM, etc. related details.
Click on Next:Add Storage.
56.8 AWS Add Storage
In step 4, we can configure storage for the instance. E.g. We can configure size of available disk or we can attach additional EBS volumes and instance store volumes. Click on Next: Tag Instance.
56.9 AWS Tag Instance

In Step 5, a tag is nothing scary but a case-sensitive key-value pair. We can keep multiple instances with same tags. We will see how it can be useful in later posts. Click on Next: Configure Security Group. 

56.10 AWS Security Groups
In Step 6, configure firewall rules that will control inbound traffic for Amazon Linux Instance. We can Add Rule. By default, SSH Rule is added for port 22. We can create or use existing security group. Click on Review and Launch.


56.11 AWS Review Instance Details
In Step 7, Review Instance Launch-Review all details of an instance and click on Launch.
56.11 AWS Review Instance Details
It will open a dialogue box of "Select an existing key pair or create a new key pair". Select a Key pair and click on Launch Instances.
56.12 AWS Select Key Pair

Verify the Launch Status.
56.13 AWS Launch Instance Status

Click on View Launch Log to find more details.

56.14 AWS Launch Instance Status Log

Click on the Amazon Ec2 Service and view the instance on Dashboard. Note Public DNS value that we will use to connect to the instance.
56.15 Amazon EC2 Service Dashboard

Once Instance State is Running, we can use putty to connect it.


To connect with newly created Amazon Linux Instance, we need Putty.

PuTTY is a open source free implementation of SSH and Telnet developed originally by Simon Tatham for Windows and Unix platforms. Download PuTTY here.

Open Putty.

In Host name, Enter Public DNS value that we noted earlier.


Use following format: ec2-user@ec2-52-38-5-202.us-west-2.compute.amazonaws.com



Now, another very important question is, what is the default user name and password?
User name is ec2-user, and as we have provided Private Key, we need not to give password while connecting to the Amazon Linux Instance.



In the Auth section, select path of the PPK File in Private key file for Authentication.

Click Open.
56.16 Putty

It will open a dialogue box for Putty Security Alert: The Server's host key is not cashed in the Registry. Click on Yes.
56.17 Putty Security Alert

It will open Putty Console using User name "ec2-user". Execute sudo yum update command to update all packages.
56.18 Amazon EC2 User

Verify other commands and directory structures too.
56.19 Amazon EC2 Instance Directory Structure

Verify ifconfig command:
56.20 Amazon EC2 Instance ifconfig

Done!

Labels: , ,