If you're new to cloud computing and looking to set up your first server, Amazon Web Services (AWS) offers a powerful tool called EC2 (Elastic Compute Cloud). EC2 allows you to run virtual machines on the cloud, making it an excellent solution for hosting websites, applications, and much more. In this easy-to-understand guide, we'll walk you through launching an EC2 instance.
What is AWS EC2?
Before we get started, let’s clarify what EC2 is. AWS EC2 (Elastic Compute Cloud) is a service provided by Amazon that allows you to rent virtual computers(also known as instances) on the cloud. You can choose the size, memory, and storage of an instance according to your needs.
For example, you can run a small instance for simple websites, or larger, more powerful instances for handling big data or running complex applications.
Why Choose EC2?
Scalability: You can start small and scale as you grow.
Cost-effective: You pay only for what you use, with flexible pricing options.
Easy to use: You don’t need to manage physical hardware or worry about server maintenance.
What You'll Need:
AWS Account: You’ll need an AWS account to get started. You can sign up for free on AWS's website.
Basic Knowledge of Web Hosting: Although this guide is for beginners, it helps to know what a virtual server is and how it functions.
Step 1: Sign into the AWS Console
Once you have set up an AWS account, sign in to the AWS Management Console. The console is where you can manage all your AWS services, including EC2.
Go to the AWS website and click on “Sign In to the Console”.
Enter your credentials to access the dashboard.
Step 2: Navigate to EC2 Dashboard
In the AWS console,
In the search bar at the top, type "EC2" and select EC2 from the drop-down list.
This will take you to the EC2 Dashboard, where all EC2-related actions are managed.
Step 3: Launch a New EC2 Instance
To launch your EC2 instance,
Click "Launch Instance" on the EC2 dashboard. This starts the process of creating your virtual server.
Choose an Amazon Machine Image (AMI):
AMI is like a pre-configured template for your instance.
Choose a popular and user-friendly AMI such as Amazon Linux 2 or Ubuntu.
You can also choose Windows Server if you need a Windows-based server, but for simplicity, we’ll go with Ubuntu.
Choose an Instance Type:
EC2 instances come in different sizes, ranging from small (like t2.micro) to large, depending on your needs.
If you’re just starting, select t2.micro under the “Free Tier” option, which is free for up to 750 hours per month for the first year.
Add Storage:
EC2 instances come with a default storage of 8 GB, but you can increase it if needed.
If you're unsure, leave the default setting.
Step 4: Select a Key Pair
A key pair is used to securely connect to your EC2 instance. This is important because it ensures that only you (or anyone with your private key) can access your server.
Create a new key pair:
Give your key pair a name (e.g., batch-9-server-key).
Download the private key (.pem file) and store it somewhere safe on your computer.
Note: You won’t be able to download the private key again, so make sure to keep it secure.
After downloading the key, check the box that you’ve acknowledged that you have downloaded the key pair, then click Launch Instances.
Configure Instance Details:
Leave most of the options in their default settings. If you’re just experimenting, you don’t need to change anything here.
Number of Instances: Set it to 1 unless you want to launch multiple instances at once.
Network: Select the default VPC (Virtual Private Cloud), which is a network of your virtual servers in the cloud.
Leave the rest of the settings as they are.
Add Tags:
Tags are like labels for your instance that help you organize your resources.
This step is optional for beginners, so you can skip it for now.
Configure Security Group:
A Security Group acts as a virtual firewall to control incoming and outgoing traffic.
Create a new security group and select SSH to allow remote access to your instance.
If you’re using a Windows Server instance, you’ll select RDP (Remote Desktop Protocol) instead.
Under SSH, set the source as Anywhere to allow access from any IP address (or limit it to your IP address for more security).
Review and Launch:
Review all your settings to make sure everything looks good.
Click Launch when you’re ready to proceed.
Step 5: Connect to Your EC2 Instance
After launching your EC2 instance, it takes a minute or two for it to be ready. You can check the status from the EC2 Dashboard.
Go to the "Instances" tab in the EC2 Dashboard.
Select the instance you just created.
Copy the Public IP address of your instance (it looks like 123.45.67.89).
How to connect to your instance?
For Linux-based Instances:
Open your terminal (or command prompt on Windows).
Navigate to the folder where you downloaded the .pem file (your key pair).
Run this command, replacing
<path-to-key>
with the path to your.pem
file and<instance-ip>
with your instance's IP address:ssh -i <path-to-key>/batch-9-server-key.pem ec2-user@<instance-ip>
You may be prompted to confirm the connection by typing
yes
.
For Windows-based Instances:
You will need to use Remote Desktop Protocol (RDP) to connect.
On the EC2 dashboard, click on Connect and follow the instructions under the RDP client tab to get your password and connect.
Step 6: Manage and Terminate Your Instance
Once you are connected to your EC2 instance, you can start setting it up—installing applications, configuring settings, or simply using it as a web server.
When you’re done with your instance, you can either:
Stop it (which pauses the instance but retains your data).
Terminate it (which deletes the instance permanently, and you will lose all data stored on it).
Make sure to stop or terminate your instance when not in use to avoid unexpected charges.
Conclusion
You've successfully launched and connected to your first AWS EC2 instance. Whether you're using it for a website, application, or learning purposes, EC2 is an incredibly flexible and scalable solution. Don’t forget to monitor your usage and costs, and explore more advanced features of AWS as you become more comfortable with the platform.
If you found this guide helpful, keep exploring AWS documentation or try creating more instances to gain deeper hands-on experience!