Creating Your First EC2 Instance
Creating Your First EC2 Instance: A Step-by-Step Guide
1. AWS Free Tier and Account Setup
Make sure you're logged into your AWS account.
Select the Northern Virginia region (US-East-1) from the AWS console.
2. Accessing the EC2 Console
Use the search bar at the top of the AWS console to find the EC2 service.
Select EC2 to go to the EC2 dashboard.
3. Creating an SSH Key Pair
In the EC2 console menu, go to Network & Security > Key Pairs.
Click on Create Key Pair.
Enter a name for the key pair (e.g., A4L).
Choose the key pair type:
RSA or ED25519 (the differences are beyond the scope of this guide).
Choose the private key file format:
.pem: for macOS, Linux, or modern Windows with SSH.
.ppk: for older Windows or PuTTY.
Click Create Key Pair. Your browser will download the private key file.
Save the key file to a secure location.
4. Launching an EC2 Instance
Return to the EC2 dashboard and click on Launch Instances.
Give the instance a name (e.g., "My First EC2 Instance").
5. Choosing an Amazon Machine Image (AMI)
Select an AMI for the operating system:
Amazon Linux 2 AMI (HVM) (free tier eligible).
Ubuntu
Windows
Red Hat
SUSE
macOS
For this guide, choose Amazon Linux 2 AMI (HVM) and leave the default settings (64-bit x86).
6. Selecting an Instance Type
Choose an instance type from the dropdown menu.
Select a free tier eligible instance type (e.g., t2.micro).
7. Key Pair Selection
Select the key pair you created earlier (e.g., A4L).
8. Network Settings
The Launch Instance wizard simplifies network settings.
VPC (Virtual Private Cloud):
By default, the instance launches into the default VPC for easy public internet access.
Subnet and Availability Zone:
Choose no preference for the subnet to let AWS select one for you.
Auto-Assign Public IP:
Enable this option to allow access from the public internet.
9. Configuring a Security Group
Create a new security group named "My First Instance SG" (and use the same for the description).
Security Group Rule:
Leave the default rule to allow SSH access from anywhere (0.0.0.0/0).
Access remains protected by the SSH key pair.
10. Storage Configuration
The default storage is defined within the AMI.
For Amazon Linux, the default is an 8GiB GP2 root volume.
11. Advanced Details
Leave the defaults for advanced options.
12. Launching the Instance
Click on Launch Instance.
After a moment, you'll see a success dialogue. Click on View All Instances.
13. Instance Status
Initially, the instance will be in a pending state and the status check will show initializing.
Wait for the instance to change to a running state and the status check to pass (this may take a few minutes).