How to Create an EC2 Instance on AWS (Step-by-Step for Beginners)

Create EC2 Instanaces

Table of Contents

Get up to 50% off now

Become a partner with CyberPanel and gain access to an incredible offer of up to 50% off on CyberPanel add-ons. Plus, as a partner, you’ll also benefit from comprehensive marketing support and a whole lot more. Join us on this journey today!

Spinning up your own virtual server on Amazon Web Services (AWS) might sound like something only system administrators do but trust me, it’s much easier than it sounds. If you’ve ever wanted to host your own website, test out a backend app, or simply learn how cloud infrastructure works, create an EC2 instance on AWS is the perfect place to start.

Throughout this guide, I’ll take you by the hand from accessing your AWS dashboard all the way through SSH-ing to your instance and even how to install a bare-bones web server. No technical babble. No assumed knowledge. Just a no-frills, gentle step-by-step from somebody who’s performed the task many dozens of times.

What is EC2?

Create an EC2 Instance on AWS

Now let’s define before we go deeper: let’s get clarity around what exactly EC2 is.

EC2 is short for Elastic Compute Cloud. It’s a main service in AWS and provides you with virtual computers (referred to as “instances”) that you can use like an ordinary computer or server. These instances reside in the cloud, which means you don’t need to purchase any hardware just sign in and fire one up.

You can control how much grunt your instance gets, what OS it’s based on, what storage it carries, and even what network you put it in. It’s flexible, you can scale as you need it, and pay only for the resources you actually use.

What You’ll Need

Before you begin clicking in the AWS interface, here is a brief summary of what you’ll need ahead of time:

Tech Delivered to Your Inbox!

Get exclusive access to all things tech-savvy, and be the first to receive 

the latest updates directly in your inbox.

  • An AWS account (free to register)
  • A basic understanding of how to use a terminal or command prompt
  • An SSH client like the macOS/Linux terminal, or PuTTY if you’re on Windows
  • A text editor (VS Code, Notepad++, or even regular Notepad)

Step 1: Log Into the AWS Console

  • Head over to https://aws.amazon.com
  • Click on the Sign In button in the top right corner and log in using your AWS credentials.
  • In the AWS top search bar, enter EC2 and click on EC2 in “Services.”
  • You will now be in the EC2 dashboard. That’s where the magic begins.

Step 2: Click on “Launch Instance”

  • Find a large orange button with the word Launch Instance written on it. Go ahead and click on that.
  • You’ll arrive at a page where you’ll begin to configure your shiny new virtual server.

Step 3: Name Your Instance

First things first, name your instance something that you’ll know later. It might be something like:

<code>my-first-server</code>
web-app-test
personal-vm

It’s just for your own reference it won’t do anything technical.

Step 4: Select an AMI (Amazon Machine Image)

This is where you select what operating system your virtual server will use.

Some popular choices:

  • Amazon Linux 2 (optimized for AWS, good for general use)
  • Ubuntu Server (my personal favorite lots of community support)
  • Red Hat Enterprise Linux
  • Windows Server

For this tutorial, I’m using Ubuntu Server 20.04 LTS. It’s stable, popular, and perfect for beginners.

Step 5: Select an Instance Type

Then, you select your “hardware.” This is the CPU, RAM, and network throughput.

If you’re just testing or learning, select the t2.micro instance it’s covered by the AWS Free Tier and is perfectly fine for light tasks.

If you’re going to be doing heavier lifting in the future, you can always scale up to something like a t3.small or m5.large, but for now, t2.micro is fine.

Step 6: Create a Key Pair (for SSH Access)

In order to create an EC2 instance on AWS and connect it to your instance securely, you’ll need to have a key pair.

Here’s what to do:

Enhance Your CyerPanel Experience Today!
Discover a world of enhanced features and show your support for our ongoing development with CyberPanel add-ons. Elevate your experience today!

  • Under Key pair (login), click Create new key pair
  • Name it — something like my-key-pair
  • Select.pem as the file type (particularly if you’re using macOS or Linux)
  • Click Create key pair — it will save the file to your machine

Important: Save this file securely. You’ll need it whenever you connect to your instance.

Step 7: Set Network Settings (Security Groups)

Security groups are essentially firewalls for your instance. Here’s what to open:

  • SSH (port 22): So you can access it through terminal
  • HTTP (port 80): To host a website
  • HTTPS (port 443): For secure web traffic

For your own IP, AWS provides you with a “My IP” option. That’s a good option for development it keeps things private and secure.

Step 8: Select Storage

Amazon provides you with a standard 8 GB of SSD storage. That’ll do for now, but you can increase it to 10 GB or 20 GB if you intend to have more software or files.

  • You can also opt for storage options such as:
  • General Purpose SSD (gp2): Optimized performance
  • Provisioned IOPS SSD (io1): For heavy apps
  • Magnetic (standard): Inexpensive but slower (not often used today)

Step 9: Launch the Instance

  • Click Launch EC2 Instance on AWS, and voilà you’ve launched your first EC2 server!
  • You’ll be brought to a page where you can see your new instance. It will take a few minutes to start up, so don’t worry.

Step 10: Connect to Your Instance (via SSH)

When your instance indicates the “Running” status, choose it and click the Connect button.

You’ll see instructions for how to connect, but here’s the quick version:

If you are using a Mac or Linux:

chmod 400 my-key-pair.pem<br>ssh -i "my-key-pair.pem" ubuntu@your-public-ip
  • Replace your-public-ip with your actual public IP address of your instance.
  • If you are using Windows, open PuTTY and:
  • Convert .pem to .ppk using PuTTYgen
  • Put in your public IP under “Host Name”
  • Load your key file under “SSH > Auth”

Step 11: Update Your Instance and Install Software

Once you’re in, it’s time to update your packages:

sudo apt update<br>sudo apt upgrade -y

Now you can install anything you want. Want to install a web server? Try:

sudo apt install nginx -y

Then access your instance’s public IP in a browser you should see the NGINX welcome screen.

Step 12: Monitoring, Stopping, or Terminating

Still in the EC2 dashboard, you can control your instance:

  • Stop it if you’re finished working for the day
  • Reboot if something crashes
  • Terminate if you don’t need it anymore
  • Be cautious with terminate this will remove your instance permanently.

Useful Hints

  • Elastic IPs: If you’d like a static public IP, think about reserving an Elastic IP
  • EBS Snapshots: Wonderful for saving a copy of your instance’s storage
  • CloudWatch: Make use of it to track performance and create alarms
  • IAM Roles: More secure than hardcoding AWS credentials inside your instance

Typical Mistakes & Fixes

Can’t SSH in?

  • Check port 22 is open on your security group
  • Make sure your key file is in the correct folder and the permission is set to 400

Page not loading within browser?

  • Check ports 80 and 443 within security group
  • Verify that the web server (such as NGINX) is running

Final Thoughts

That’s it! You’ve officially launched and attached to your first EC2 instance on AWS. Now that you’re here, the sky’s the limit. You can install a web framework, deploy an application, learn DevOps tools, or use it as a test server.

AWS can be daunting at first. But after you pass the initial learning curve, EC2 is an amazingly powerful tool in your cloud arsenal.

FAQs

What is an EC2 instance?

An EC2 instance on AWS is a virtual server within Amazon’s Elastic Compute Cloud (EC2) infrastructure. It lets you run applications on the cloud just as you would on a physical server without worrying about hardware.

What are EC2 instance types?

Instance types are CPU, memory, storage, and networking capacity configurations. AWS provides numerous instance types that are optimized for various tasks, including general purpose (t2, t3), compute-optimized (c5), memory-optimized (r5), and GPU-based (g4) instances.

Is EC2 free to use?

Yes, AWS provides a Free Tier that includes 750 hours per month of use for a t2.micro or t3.micro instance for up to 12 months after signing up. After that, it is billed by the hour or by the second, depending on the type of instance.

How do I access my EC2 instance?

You connect to your EC2 instance on AWS using SSH (for Linux/Unix) or RDP (for Windows). You’ll use a private key file (.pem) generated during setup and the public IP address of the instance.

Shumail
Shumail is a skilled content writer specializing in web content and social media management, she simplifies complex ideas to engage diverse audiences. She specializes in article writing, copywriting, and guest posting. With a creative and results-driven approach, she brings fresh perspectives and attention to detail to every project, crafting impactful content strategies that drive success.
Unlock Benefits

Become a Community Member

SIMPLIFY SETUP, MAXIMIZE EFFICIENCY!
Setting up CyberPanel is a breeze. We’ll handle the installation so you can concentrate on your website. Start now for a secure, stable, and blazing-fast performance!