DEV Community

Victor
Victor

Posted on

🖥 How to Create Your First AWS EC2 Instance: A Step-by-Step Guide for Beginners

🖥 How to Create Your First AWS EC2 Instance: A Step-by-Step Guide for Beginners

If you’ve ever wanted to deploy a server on the cloud, Amazon Web Services (AWS) is one of the best places to start. AWS offers a flexible and powerful computing platform called EC2 (Elastic Compute Cloud) which allows you to launch virtual machines (called instances) within minutes.

In this guide, we’ll walk through how to create and connect to your first AWS EC2 instance, using the AWS Management Console. Whether you’re learning cloud computing or building your first web app, this tutorial is all you need to get started.

🧭 Step 1: Sign in to Your AWS Account

Head over to Visit AWS and log in to your account.
If you don’t have one yet, create a free AWS account, you’ll automatically get access to the AWS Free Tier, which allows you to use certain resources (like the t2.micro instance) at no cost for 12 months.

Once logged in, go to the EC2 Dashboard by searching for “EC2” in the AWS console search bar.

⚙ Step 2: Launch a New Instance

On the EC2 dashboard, click “Launch Instance.” This opens the setup wizard where you’ll define your instance settings such as OS, instance type, storage, and security configurations.

🧩 Step 3: Choose an Amazon Machine Image (AMI)

An AMI (Amazon Machine Image) is basically the operating system template for your instance.
You can choose from:
• Amazon Linux 2 –ideal for beginners, optimized for AWS.
• Ubuntu – a popular choice for developers and open-source projects.
• Windows Server – if you’re running Windows applications.

For this tutorial, select Windows(Free Tier eligible).

⚡ Step 4: Choose an Instance Type

Next, you’ll select your instance’s hardware configuration — CPU, RAM, and network performance.

For beginners or free-tier users, select t3.micro or t3.micro. These offer 1 vCPU and 1 GB of memory, perfect for testing or learning.

Click “Next” to move forward.

🪣 Step 5: Configure Storage and Tags

By default, AWS assigns a root volume (EBS) to store your operating system files. You can leave this as it is or increase the storage size if needed.

Then add a tag to name your instance.
Example:

• Key: Name
• Value: MyFirstEC2

Tags help you identify your resources later, especially when managing multiple instances.

🔐 Step 6: Set Up a Security Group

Security groups act like a virtual firewall for your instance controlling what traffic can enter or leave.
• Click “Create a new security group.”
• For a Linux instance, add a rule to allow SSH (port 22) from your IP address only.
• For a Windows instance, allow RDP (port 3389) instead.

⚠ Important: Never open your SSH port (22) to “0.0.0.0/0” — this exposes your instance to the entire internet. Restrict it to your own IP for safety.

🗝 Step 7: Create or Choose a Key Pair

You’ll need a key pair to securely connect to your instance.
• Select “Create a new key pair.”
• Give it a name (e.g., mykeypair).
• Download the .pem file immediately AWS won’t let you download it again later.

Keep this file safe; it’s your only way to SSH into your instance.

🚀 Step 8: Launch Your Instance

Click “Launch Instance” and wait for AWS to deploy it.
You’ll be redirected to the Instances page, where you can see your new EC2 instance initializing.


Once its Status changes to running and both health checks pass, your cloud server is officially live! 🎉

🔌 Step 9: Connect to Your EC2 Instance

Now it’s time to access your server.
1. Select your instance and click “Connect.”
2. Choose “SSH client.”
3. Copy the provided SSH command — it looks like this:

ssh -i "mykeypair.pem" ec2-user@ec2-XX-XXX-XX-XX.compute-1.amazonaws.com

  1. Open your terminal and navigate to the folder where your .pem file is stored.

  2. Run the command above (replace with your instance’s actual public DNS).

✅ If everything goes well, you’re now inside your EC2 instance’s command line.

🧹 Step 10: Manage Costs and Security

Before you finish, keep a few key points in mind:
• Stop vs. Terminate: Stopping an instance pauses it (you can restart later). Terminating deletes it completely.
• Elastic IP: To keep a fixed public IP address, allocate and attach an Elastic IP.
• Monitor usage: Even free-tier users can incur small storage or data transfer costs if instances run continuously.

When you’re done experimenting, it’s a good idea to stop or terminate your instance to avoid unnecessary charges.

✅ Conclusion

Creating an EC2 instance on AWS might sound technical at first, but as you can see, it’s actually quite simple. In just a few clicks, you’ve learned how to launch, connect, and manage a cloud-based server.

From here, you can start hosting websites, deploying applications, or experimenting with other AWS services like S3, RDS, or Lambda.

Your first instance is just the beginning, welcome to the world of cloud computing! ☁

Top comments (0)