Amazon EC2 Instances

An EC2 instance is a virtual server in Amazon’s Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure.

Think it as a regular machine with OS according to your choice. you can say it a copy of the computer with its own RAM, HDD, OS. The only difference is that it is totally virtual and you can run multiple virtual computers on a single physical hardware.

Amazon provides a variety of instances with different configurations of CPU, memory and storage according to user needs. Instance types are grouped into families based on target application profiles. These groups include: general purpose, compute-optimized, GPU instances, memory optimized, storage-optimized and micro instances.

We will take an example of how we can make an EC2 instance from AWS management console-

1- Log into the AWS Management Console.

2- Launch an Amazon EC2 instance** :**
In the Amazon EC2 Dashboard, click on “Launch Instance”.

3. Configure:

In this wizard, you have the option to configure your instance features. Below are some guidelines on setting up your first instance-

Step 1- Choose an Amazon Machine Image (AMI):

In step 1 of the wizard, You will be asked to choose an AMI of your choice. (An AMI is an Amazon Machine Image. It is a template basically of an Operating System platform which you can use as a base to create your instance). Once you launch an EC2 instance from your preferred AMI, the instance will automatically be booted with the desired OS. I recommend the Amazon Linux AMI (free-tier-eligible).

Step 2 - Choose an instance type:

In this step, you have to select the type of instance you require based on your business needs. I recommend the t2.micro (free-tier-eligible).

Step 3 - Configure instance:

in this step, you can provision up to 20 instances at a time. We can configure some basic networking details, subnet, IAM role and other configurations for our EC2 server. It is better to determine and plan this prior to launching the instance. If you are not aware of the above configuration details then you can skip this step.

Step 4 - Add storage:

In the Add Storage step, you’ll see that the instance has been automatically provisioned a General Purpose SSD root volume of 8GB. ( Maximum volume size we can give to a General Purpose volume is 16GB).
You can change your volume size, add new volumes, change the volume type, etc.

Step 5- Add Tags:

You can add a tag for your instance with a key-value pair. This gives visibility to the AWS account administrator when there are numbers of instances.

Step - 6 Security group: 

It, gives you the luxury to restrict the traffic on your instance ports. This is an added firewall mechanism provided by AWS apart from your instance’s OS firewall.

Step - 7 Launch Instance: 

In step 7, review your instance configuration and choose “Launch”.

Create key pair: 

Now you will be asked to create a key pair to log in to you an instance. A key pair is a set of public and private keys.

Select “Create a new key pair” and assign a name to it. file (.pem) will be download automatically.
AWS stores the private key in the instance, and you will be asked to download the public key. Please make sure that you download the key and keep it safe and secured. If it is lost, game over, you cannot download it again.

1: Select create a new key pair.
2: Give any name to the key.
3: Download it and save it in your folder.

Note: It may take a few minutes to initialise your instance.

4. Connect to your instance:

You can use the following command on your terminal to set the permissions of your key file:

chmod 400 /path/my-key-pair.pem

Use the ssh command to connect to the instance. Specify the private key (xyz.pem) file and user_name@your___public_dns_name. For example, if you selected Amazon Linux 2 or the Amazon Linux AMI, the user name should be ec2-user

<code><code>ssh -i /path/my-key-pair.pem [email protected]

Alternatively, you can also connect to the instance using IPv6 address. 

ssh -i /path/my-key-pair.pem ec2-user@2001:db8:1234:1a00:9691:9503:25ad:1761

You will see a response like following:

<code><code>The authenticity of host ' (' can't be established. RSA key fingerprint is 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f. Are you sure you want to continue connecting (yes/no)?</code></code>

Enter yes. You see a response like following:

<code><code>Warning: Permanently added '' (RSA)  to the list of known hosts.</code></code>

Now you’re logged in on your ec2 instance. That’s as short as I can keep this post.