# Amazon EC2 Instance

Howdy everyone, Finally I am back with some content. It has always been with Amazon web services. In earlier days, It is hard to predict how much computational power was needed for an application to launch. If we underestimated the computational server is going to crash. If we overestimated we need to pay irrespective of the usage.

Here comes the <mark>Amazon EC2</mark>. It is a similar kind of thing used to set up a Virtual server with everything like OS, Networking, Storage, etc. It also offers <mark>Security, Scalability, Reliability, </mark> and more.

Today we will see how to launch an EC2 Instance.

### Steps to launch an EC2 instance in AWS Console:

This is what the AWS console looks like; You can choose which region you want to choose the region which is near (It will minimize the latency).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683016314506/045fd2e3-e72e-4492-8f90-d0f15aadb97e.png align="center")

Now search for EC2;

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683016468771/caf60a9b-c4ce-4692-9b7c-eba89174de54.png align="center")

After clicking on EC2, you will get to see the EC2 dashboard below:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683016561071/9f7cc05e-31c8-4fa5-bddc-8da7328ee728.png align="center")

Where you can find more information like the number of instances running, the Load balancer, service health, and more.

Let us create an EC2 instance:

1. Click on the instance, and you can see below now we need to click on launch instances and choose the first option for now.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683017183396/33aabed6-36f6-420a-bfcb-4621aaedc117.png align="center")

2)Name your instance and choose OS you want to use like Linux,macOS , Redhat , and more. Select the particular AMI(Amazon Machine Image).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020533761/08782bd8-e18e-4f81-9308-0f5fc4e146ae.png align="center")

3)We need to choose the instance depending on optimizations like computing power, storage, memory, networking, and capacity. Please, make sure you were opting for a <mark>free-tier instance</mark> so you won't get billed if your doing hands-on.

<mark>t2-micro </mark> is free tier with 1vCPU,1GiB memory

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020605392/526dd611-a98c-4178-b735-57b749e7e320.png align="center")

You can compare the instance types and choose according to that as below:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683029034842/78d6ef09-7952-4c6e-9cc0-b26082afe8db.png align="center")

4)Next Step is to create a <mark>key pair</mark> and download it which allows us to connect instances securely.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020631250/9a25fe7f-542f-4ece-865f-936abcd98498.png align="center")

5)Now we need to create a security group as below make sure SSH access is enabled if not you cannot connect to the instance (there is another way like <mark>EC2 Connect</mark> without enabling the ssh we can still connect to the instance).

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020674649/ca59cb4b-3939-41bd-9884-13dee5cdf26b.png align="center")

6)Configure your storage here by default for free tier-eligible customers can get up to 30GB of EBS SSD.

Here we need to change the option for <mark>Delete on Termination to no</mark>. Because when the instance got terminated the data will perish too.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683021768831/e8787149-4467-4532-a938-3165af56d261.png align="left")

7)Now click on Launch instance and get back to the instances dashboard you can see our instance which is created was up and running.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020769183/4e11cdb8-f836-46f8-9439-9d381501cbc0.png align="center")

### Instance Summary

After successfully creating the we can see below :

Public IPv4 address, Private IPv4 address, instance type, Vpc id, and more (<mark>Note: Public IPv4 address will change whenever we reboot the instance. To make it static we need to make it an Elastic IP Address</mark>)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020787670/8678b9a3-1e00-433d-8348-aede89680867.png align="center")

There are 5 instance states :

1)Start instance : It makes the instance up and running

2)Stop instance: It totally stops the instance.

3)Reboot instance : it reboots the instance

4)Hibernate instance: It totally stops the instance for some time all the data will be stored. we can set this behavior while configuring the instance.

5)Terminate instance: It totally terminates/kills the instance.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683020841518/4a1831eb-a06c-440f-be8c-a15955ff6cd4.png align="center")

To change the instance type we need to stop the instance and go to <mark>Actions</mark> click on <mark>Instance settings</mark> we can modify it there.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683616573796/fc076e5e-2d0b-487a-ac5a-05be1216ecd2.png align="center")

To connect to the instance we need to click on connect button(<mark>Note: for this, we don't need to make security with ssh allow access</mark>)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683616838933/24e62162-b403-45ed-b92d-7375b9b9f0a4.png align="center")

### Enhanced networking

The command used to check information regarding the network driver

Newer generation instances by default use <mark>ENA as the network driver</mark>. Older generation instances use <mark>vif as a network driver</mark>.

```powershell
[ec2-user@ip-172-31-43-179 ~]$ modinfo ena
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683021284763/8842027f-035c-464e-8d34-e1de1fb6c0d8.png align="center")

To check the driver info use the below command (<mark>Note: this command works for Amazon Linux 2023</mark>)

```powershell
ethtool -i enX0 # for amazon linux 2023 and older generation instance
ethtool -i ens5 # for new generation instance
ethtool -i eth0 # for Amazon Linux 2022 and new generation instances
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1683615040270/953ca895-c3ee-4c04-b4b6-338c8cf5e3b8.png align="center")

That's all Happy Instancing :)
