# Creating an EC2 Instance on AWS: A Step-by-Step Guide for Beginners

# What is AWS?

AWS is Amazon’s Cloud Service.

It let’s you

1. Rent servers
    
2. Upload objects (mp4 files, jpegs, mp3s …)
    
3. Autoscale servers
    
4. Create k8s clusters
    

 The offering we will be focusing on today is `Renting servers.`

Prerequisites: Before we dive in, ensure you have the following:

1. [An AWS account.](https://aws.amazon.com/)
    
2. SSH key pair for accessing your EC2 instance.
    

---

# What is an EC2 instance?

Virtual Machines on AWS are called EC2 (Elastic Compute Cloud).

1. **Elastic**: As the name suggests, we can increase/decrease the size of the machine.
    
2. **Compute**: It is a machine.
    

You can fire up a new EC2 instance from the AWS dashboard.

![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F085e8ad8-528e-47d7-8922-a23dc4016453%2Ff0ee3fa6-e989-4982-a580-e8039c48ae62%2FScreenshot_2024-02-11_at_6.33.46_AM.png?table=block&id=3dc2315f-4c68-4d34-995e-c56ba0d08feb&cache=v2 align="left")

---

# Creating a new EC2 instance

1. Click on `Launch Instances.`
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709547522959/d0e91219-d7ec-4118-b6ea-329d68b1de91.png align="center")

2. Give a name to your instance.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709547913500/6e625b3d-6fb6-4852-957c-65fe5fc71d31.png align="center")

3. Select an Operating System (OS).
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548119877/48c94b75-0cb6-49b8-ae23-eba93c973552.png align="center")

4. Select Size
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548262698/003d0772-34f3-4a3f-96e7-31606ac8beb3.png align="center")

5. Create a new key pair.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548374126/ad6f55be-0db3-48d2-ac76-7d270acac5da.png align="center")

Now create a new key pair by providing a name, then click on `create key pair.`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548452626/fba4dce0-851c-4207-8aa1-e4420c919243.png align="center")

Now it'll download a `test101.pem` file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548537083/7de728fd-a59a-4991-aab4-f8895a764cf9.png align="center")

6. Select Storage Size
    

![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2F085e8ad8-528e-47d7-8922-a23dc4016453%2F4f28c0ac-7f35-4200-a0e6-21df5ac982b3%2FScreenshot_2024-02-11_at_6.38.05_AM.png?table=block&id=f32975d3-a6ee-4a3b-a666-33eb338ff4fe&cache=v2 align="left")

7. Allow traffic on **http/https.**
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709548863721/ad7b20d4-304e-459f-9f19-d4b91700b85b.png align="center")

8. Launch the instance
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709549228434/5e45c68e-e672-4adc-a06c-48c9947a086c.png align="center")

---

# Connection using SSH into instance

First open your terminal and then navigate to the folder where your `test101.pem` has been downloaded.

```bash
cd Downloads
```

1. Give SSH Key Permissions.
    

```bash
chmod 700 test101.pem
```

2. SSH into machine
    

Copy the IP address of the instance.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709549487594/b731cf36-03ae-4137-95cc-42a62ace7a86.png align="center")

```bash
ssh -i test101.pem ubuntu@54.89.21.166
```

3. It's Done!
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709549702146/b0d24c17-59d0-4e5f-a320-fea8206b727b.png align="center")

As you can see our Linux server is running.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1709549709996/532b3b38-bd7f-4e60-9117-35340ff6e0eb.png align="center")

Congratulations! You've successfully created your first EC2 instance on AWS. You can now start using it for various purposes such as hosting websites, running applications, or conducting experiments in a sandbox environment.

---

# Conclusion

Creating an EC2 instance on AWS is a straightforward process, especially with this step-by-step guide for beginners. By following these steps, you can quickly set up your own virtual server in the cloud and start exploring the vast possibilities of cloud computing with AWS. So, what are you waiting for? Dive in and start building your cloud infrastructure today!
