Setting Up An Ubuntu EC2 Instance From Scratch on AWS
Tags: cloud, aws, beginners, devops
Published: 2023-07-06 07:23:26

In this article, we will be setting up an Ubuntu EC2 instance from scratch on AWS. Amazon EC2 is a web service that provides scalable and inexpensive compute power in the cloud. Feel free to checkout the below video I made for this tutorial as well.

{% youtube UeTSPBvE2vs %}

## Steps To Create Ubuntu Instance on AWS

Amazon EC2 makes it easy to set up a virtual machine (VM) running Ubuntu on AWS.

### Selecting AWS Region

To create a Ubuntu instance on AWS, you first need to select an EC2 region. In this tutorial we will be using the **ap-south-1** region as it has low latency and availability for us.

![aws-region](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gdyzvttox20nbskmly1.png)

### Configuring Our AWS Instance

Now you'll need to name your AWS Instance and select the Operating System(OS) to run on your AWS Instance. For this tutorial, we'll be going with the **Ubuntu 22.04 LTS** Version which is also part of the AWS Free Tier.


![aws-instance-name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ve7mdssmfu32qu6o3n8n.png)

![aws-instance-os](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9bd9bnfxpdhiqa9gsvj.png)

Now, You need to choose an **instance type** and **instance size**. You will have to choose how many CPUs and how much memory you want for your Ubuntu instance. You can also change this later on but it is not recommended unless you know what you are doing. I am going with the `t2.micro` instance size for this tutorial.

![aws-instance-size](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o0l6az01hkkddlf8vpb4.png)

Now you will be prompted to assign a key pair to access your instance.
Select **Create A New Key Pair**.
Enter a name to your key.
Click Create.

![aws-keypair-1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjh9frot00072em5l7m7.png)

![aws-keypair-2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y7xuktcaqddepgn1f1z0.png)

_Important: Save the key pair, if you miss this key you wont be able to access your instance using SSH._

Now select the **Disk Size** you want, you can choose different disk type as well and select tags for your instance.

![aws-instance-disk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ieuyxwqhcwv20l2pzsvk.png)

Then click on "launch" button and wait until it connects with AWS servers in few minutes. After that your Ubuntu EC2 Instance is ready!

![aws-instance-launch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjfd5hi8gxkgf77ydb99.png)

Let it setup itself, takes approx few seconds to minutes.
It should show **Pending** and once it's ready, it's state should change to **Running**

![aws-launch-pending](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uom4pzv07ssny7mcw7m1.png)

![aws-launch-running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tfar5ld49le2x4iw92nz.png)

### Connecting to our AWS Instance

Now we'll head to the instance details and click on **Connect**. Ideally you would want to use `ssh` to connect to your EC2 instance but for this tutorial, we'll be using the WebUI. The default username is `ubuntu` so click Connect.

![aws-connect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/88imgihdv81f0y0ymftl.png)

YAY!!🥳 And there's our welcome message to Ubuntu which is running on AWS.

![aws-welcome](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa9dcpndtis878g16ts3.png)

### Extra

Now we'll install neofetch and check system configuration of the virtual machine. Run the following commands.

```sudo apt update```

```sudo apt upgrade -y```

```sudo apt install neofetch -y```

And there you go! Now it shows up our virtual machine specification in the terminal and in friendly design-style.

![aws-neofetch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bl8s1ra608bqixai7h0t.png)

## Conclusion

Setting up an Ubuntu EC2 instance from scratch on AWS is a fun little project. It's relatively easy, and it gives you an opportunity to learn some more about AWS and the command line.

Thank you for reading! If you found this blog post helpful, please consider sharing it with others who might benefit. Feel free to check out my other blog posts and visit my socials!

- [Profile](https://bio.link/devarshishimpi)
- [Linkedin](https://linkedin.com/in/devarshi-shimpi)
- [Twitter](https://twitter.com/devarshishimpi)
- [Youtube](https://youtube.com/@devarshishimpi)
- [Hashnode](https://devarshishimpi.hashnode.dev)
- [DEV](https://dev.to/devarshishimpi)

### Read more

- [Self-Hosting Your Own Cloud Storage on AWS using NextCloud](https://blog.devarshi.dev/self-hosting-your-own-cloud-storage-on-aws-using-nextcloud)
- [Creating Your First Droplet - DigitalOcean Tutorials](https://blog.devarshi.dev/creating-your-first-droplet-digitalocean-tutorials)
- [Complete Markdown Tutorial for Beginners](https://blog.devarshi.dev/complete-markdown-tutorial-for-beginners)