
Introduction to AWS EC2: Building Your First Cloud Server
Amazon EC2 lets you rent a virtual server in AWS's data centers with a few clicks, and the free tier makes it practical for learning. Creating your first instance comes down to six settings (region, AMI, instance type, key pair, security group, storage), after which you connect over SSH from a terminal.
Why do you need a server for a web application?
An app that only runs on your computer's local host (localhost:3000) is only half complete. To let anyone in the world access it, you need a computer that is always on and connected to the Internet: a Server.
In the past, you had to buy your own server computer and connect network cables. Now, thanks to cloud computing, you can rent a powerful virtual server in about 5 minutes with just a few clicks. This guide covers EC2 (Elastic Compute Cloud), the most basic core service of Amazon Web Services (AWS), the world's No. 1 cloud service, and walks through creating an instance.
What is EC2 (Elastic Compute Cloud)?
EC2 is a flexibly sized virtual server hosting service provided by AWS. Simply put, it means "borrowing as much of the resources (CPU, RAM, disk) of high-performance computers in Amazon's huge data centers as you want".
Key features of EC2
- Elasticity: You can optimize costs by raising server performance or adding servers (Scale-up/out) when traffic is high, and scaling back down (Scale-down/in) when traffic decreases.
- Various operating systems: You can choose the operating system (AMI) you want, including Linux (Ubuntu, Amazon Linux, etc.) and Windows Server.
- Billing per second: It uses a pay-as-you-go model where you pay only for the time the server is running, so there is no upfront infrastructure cost.
- Free Tier: New subscribers can use
t2.microinstances for 750 hours per month (effectively an entire month) for free for one year. Perfect for learning!
How do you create an EC2 instance?
The AWS console screens change frequently and can look complex, but the core setup steps are always the same:
1. Select region
Choose the physical location of the AWS data center. If Korean users are your main target, select 'Asia Pacific (Seoul) - ap-northeast-2' in the upper right corner to minimize network latency.
2. Select AMI (Amazon Machine Image)
Just as you choose between Android and iOS when buying a smartphone, this step chooses the server's operating system. For beginners, the latest LTS version of Ubuntu Server is recommended because it has the largest community support and is easy to use. Check for the 'Free Tier Available' mark.
3. Select Instance Type
Decide the server's hardware specifications (number of CPU cores, memory capacity). Select t2.micro, which the free tier covers. (In some regions t3.micro is the free tier option, so check the mark.)
4. Generate and download key pair
This is the most important step for security! Create a master key (used instead of a password) for remote SSH access to the EC2 server. Select the RSA method and download it in .pem format.
Caution: This key file can only be downloaded once, so keep it in a safe place where it cannot be lost or leaked. Be extremely careful not to accidentally upload it to GitHub.
5. Network and Security Group Settings
A security group is a virtual firewall around the server that decides which ports accept incoming traffic.
- SSH (port 22): Must be open so you can access and manage the server remotely. Where possible, set the source type to 'My IP' so only you can connect.
- HTTP (port 80) / HTTPS (port 443): To run a web server that general users can reach, open these ports to 'Anywhere'.
6. Storage (EBS) configuration
Set the server's hard disk (SSD) capacity. The Free Tier allows up to 30GB for free, so it is a good idea to raise it from the default (8GB) to 30GB.
How do you connect to an EC2 instance from a terminal (Mac/Linux)?
Once the instance status is 'Running', note its assigned 'Public IPv4 Address', open a terminal, and connect using the downloaded key pair (.pem).
# 1. Change the permissions of the key pair file so that only you can read it. (Very important!)
chmod 400 my-key-pair.pem
# 2. Connect to the server using the SSH command. (The default username for Ubuntu AMI is ubuntu.)
ssh -i /path/my-key-pair.pem ubuntu@public_IP_address
On the first connection, enter yes when asked whether to continue with the fingerprint. If your terminal prompt changes to ubuntu@ip-172-xx-xx-xx:~$, congratulations: you are connected to your own cloud server.
What should you do after connecting?
You can now install Node.js on this empty Ubuntu server, pull your code with Git, and launch your app. EC2 is the most basic service, but it is the first step to understanding cloud infrastructure. Don't forget to 'stop' or 'terminate (delete)' your instance when not in use to avoid a huge bill!






