How to Create an EC2 Instance in AWS


Amazon Web Services (AWS) provides many cloud services, which can feel overwhelming for first-time users—even with its user-friendly interface. Beginners often wonder where to create a virtual machine in AWS. In AWS, a virtual machine is called an EC2 (Elastic Compute Cloud) instance, and it is used to run servers and applications in the cloud.

In this guide, you’ll learn how to create an EC2 instance in AWS step by step, along with beginner best practices to help you launch your first cloud server confidently and correctly.

What Is an EC2 Instance in AWS?

In AWS an EC2  (Elastic Compute Cloud) instance is a virtual machine that allows you to run applications, host websites, or perform server-side tasks in the cloud. Instead of buying physical hardware, AWS lets you launch virtual machines on demand and pay only for what you use.

We typically use them for:
  • Hosting websites and web applications
  • Running backend services or APIs
  • Setting up test environments 

Prerequisites Before Creating an EC2 Instance

Before creating an EC2 instance in AWS, make sure you have the following:
  • An active AWS account
    • For learning, go for an AWS Free Tier–eligible account. It offers limited free usage and often includes promotional credits, so you can practice without surprise bills.
  • Basic awareness of AWS regions
    • AWS Regions are geographic locations around the world (like US East, Europe, Asia Pacific, etc.). While region selection doesn't change the step-by-step process of creating an EC2 instance, it does affect performance — specifically the latency (delay) when you connect to your instance (e.g., via SSH) or when users access services/websites you host on it. Therefore, choose a region close to your physical location (or your target users) for the fastest experience.

EC2 Instance Creation

Step 01: Sign in to the AWS Management Console

Log into AWS Management Console using your user credentials.




Step 02: Open the EC2 Dashboard

Either click on the "EC2" link in the "Recently Visited" section on AWS Management Console or search "EC2" using the search box in the navigation bar, and select "EC2 - Virtual Servers in the Cloud" option to open the EC2 Dashboard.

Step 03: Instance Creation

You can start the instance creation either directly from the dashboard by clicking on "Launch instance" - Yellow button on the top right corner.

Or by navigating to "Instances" section and clicking on "Launch instance" button from there.


Naming the Instance

Both of these methods will take you to a section that lets you configure the parameters of your EC2 instance. First you need to give a name or tags to your instance. While you can create an instance without neither of them, it is recommended to add name or tags to your instance to uniquely identify them. Name is just a title, and a tag is just a label configured using a key value pair. In this guide I will just use a name for my instance.

Choosing an OS Image/AMI

Now it is the time to select the OS image or AMI (Amazon Machine Image) for your EC2 instance. You select the OS and its version by selecting the OS from the quick start and selecting the version from the drop down menu. If you can't find the version you want, you can try using the search bar in the "Application and OS Images  (Amazon Machine Image)"section. For this guide I will select "Ubuntu 24.04"


It is not required, but you can also change the OS architecture. I will leave it as it is for the guide.

Instance Type

Instance type defines, how much CPU and RAM is allocated for your instance, and the cost per hour for using the instance based on the OS you are using. For learning how to create an EC2 instance you can select the smallest available, but for production you should choose one that matches your system requirements and budget. Your instance will hang if you don't have enough resources for the services you are configuring, but using a larger instance types without thinking might lead to unexpected costs.


Key Pairs

A key pair is a set of cryptographic keys (a public key and a private key) used to securely authenticate and access an EC2 instance instead of a password. In simple terms it is like a lock and the key. 
  • Public Key: Stored in EC2 instances
  • Private Key(.pem or .ppk): Kept by the user
In this section, you can either create a new key pair or use an existing key pair. While you can also proceed without using a key pair, it is recommended to use one.


If you have previously created key pairs you can use them from the following list. But if you are creating an EC2 instance for the first time, this list will most probably be empty. 

If you are creating a key pair, it is required to give a name to the key pair, and select key pair type & format. 
  • Key pair type: Defines the algorithm used for generating the key pair
    • RSA: Older, and widely supported algorithm. Choose this if you want backward compatibility.
    • ED25519: Modern algorithm with built-in protection against common attacks.
  • Key file format: Use .pem if you are connecting to the instance using the terminal/cmd, and use .ppk if you are using PuTTY to connect to the EC2 instance.
For the demonstration I will go with RSA and .pem.



Note: Whether you create a new key pair or use an existing one, make sure you download and securely store the private key at the time of creation. You will need this key to SSH into Linux instances or to retrieve the Administrator password for Windows instances. If the private key is lost, you will not be able to access the instance later.

Network Settings

This is where you configure network related settings including subnets, automatic public ip assignment, and firewall settings (security groups). You can leave everything except firewall settings as it is. Similar to key pairs, you can either create a new security group or use an existing one.

When creating a new security group, make sure you enable “Allow SSH traffic from” at a minimum. Otherwise, you will not be able to log in to your instance. 


You can choose to allow SSH access from anywhere, from a specific subnet, or only from your public IP address (recommended if your public IP is static and you are the only person accessing the instance via SSH). If you are creating the instance for a web server, select "Allow HTTPS traffic from the internet" & "Allow HTTP traffic from the internet" as well.


You can use any previously created security group by selecting the option "Select existing security group".

Configure Storage

This defines the capacity of the storage volume attached to the EC2 instance. You can increase the size or add additional volumes later based on your requirements. For learning or test setups, the default capacity is usually more than sufficient.

Advanced details

You can keep all the default configurations in this section for now.






Launch Instance

View the details in the "Summary" section on the top right corner on your screen. Set the number of instances you want to create and click "Launch Instance"

Wait until the instance is created and click on the instance ID to view the instance information.

Clicking on the instance ID will take you to the "Instances" section, and you can manage your newly created instance from here.


To connect to the created instance click on the "Connect" button on the top right corner. This will take you to the "Connect to instance" section. 

Connecting to a Linux EC2 Instance

Go the "SSH Client" section to view details required to SSH to the instance. 





Use the displayed information to SSH into your EC2 instance.



Windows EC2 instance

If it is a Windows EC2 instance, go to "RDP" client section and upload your previously downloaded private key to view the password for the administrator account.






Troubleshooting

Can't connect to the instance

  • Double-check the SSH rules in the Security Group attached to the EC2 instance.
  • Ensure that SSH access is allowed.

Can't authenticate or view the administrator account's password

  • Make sure you downloaded the correct private key and are using the same key pair that was assigned to the instance.

EC2 instance suddenly hung after installing some services

  • Ensure you selected an instance type with sufficient CPU and memory for the services you installed.

Managing Instances

You can manage all of your created instances from the "Instances" section in the "EC2 Dashboard".

With this, you’ve successfully learned how to create and access an EC2 instance in AWS. While the initial setup may feel overwhelming at first, the process becomes much easier as you get familiar with the AWS interface and core concepts. Start small, experiment within the Free Tier, and gradually explore more services as your confidence grows. AWS offers powerful tools, and EC2 is the foundation for running servers and applications in the cloud.



Comments