How to create an EC2 instance in AWS

Manish Mandal
5 min readJul 19, 2023

Today in this tutorial we will learn how to set up our first EC2 instance in AWS.

So what exactly is EC2 in AWS?

Amazon EC2 (Elastic Compute Cloud) is a web service provided by Amazon Web Services (AWS) that allows users to rent virtual servers, also known as instances, on the cloud. EC2 provides resizable compute capacity in the cloud, which means you can easily scale your computing resources up or down based on your needs.

With EC2, users can launch instances with a variety of operating systems, configurations, and software applications. This makes it a highly flexible and powerful service for running applications, hosting websites, running databases, and performing various computing tasks in the cloud.

So let us see how can we create one

Step 1: Sign in to your AWS Console

Sign in to your AWS account via the AWS Management Console (https://console.aws.amazon.com/).

Step 2: Select EC2 service

Once logged in, choose EC2 from the list of services. It is located in the Compute category.

Step 3: Choose a Region

Choose the AWS Region in which you wish to provision the EC2 server in the top right corner of the EC2 dashboard.

Step 4: Launch Instance

Click on the Launch Instance button to start the instance creation process.

Step 5: Enter Server Name

After clicking on the Launch Instance button a new page will appear where you can enter the name of your server and also select its configuration. You can enter the name of your server in the below box.

Step 6: Choose an Amazon Machine Image (AMI)

Choose the AMI that matches the operating system and configuration of your EC2 instance. AWS provides a variety of pre-configured AMIs, including Linux, Windows, and other operating systems.

For tutorial purposes, I’ll choose the Ubuntu server but you can select another operating system as per your choice.

Step 7: Choose an Instance Type

Choose the instance type based on your needs. CPU, memory, storage, and network performance differ amongst instance types. For tutorial purposes, I have used t2.micro as it’s only available in the free tier.

Step 8: Create new key pair

Here you need to create a key pair that will help you securely log in to your server using a terminal or putty. Click on Create new key pair and a new popup box will appear. Enter the below details to create one and press create key pair button on the popup.

Here I have used a .pem file as I will be using my inbuilt terminal to connect through OpenSSH. If you want to use putty then you can select the .ppk option. After clicking on create key pair button the key will be downloaded. Save it somewhere as it’s important to log in to your server.

Step 9: Set Network settings

Here you just need to create security group setting which will allow us to open our server IP for SSH and bowser.

Step 10: Configure Storage.

Specify the amount and type of storage for your instance. You can also add additional volumes as needed. By default, it’s 8GB storage and in the free tier, you can extend it to 30GB.

Step 11: Launch the Instance with the configuration.

After reviewing, click on the Launch Instance button.

Step 12: Successfully Created

You’ll see a confirmation message after the instance has been launched. To obtain additional information about your new EC2 instance, click the instance ID.

Step 13: Connect to the server using the terminal.

After clicking on the instance ID you will be redirected to EC2 Management Console. Select your instance and click on connect button on the top right side.

A new page will open now go to the SSH Client tab here you will see the command that we can use to connect to our server.

Now put your private key which we have created and downloaded in step 8 in a folder and open the terminal in the same folder and paste the above command which you copied in the terminal and hit enter. You will be connected to you server

Note: If you are using mac or Linux run the command as sudo use and for windows users you should open terminal as administrator.

That’s it for today.

For any query, you can get in touch with me via LinkedIn

--

--

Manish Mandal

Full Stack Developer | React JS | Next JS | Node JS | Vue JS | Wordpress. Connect with me https://www.linkedin.com/in/manishmandal21/