Create EC2 Server
Deploying Amazon EC2 Instances
ℹ️ Overview
- Amazon EC2 (Elastic Compute Cloud) lets you deploy virtual servers in the AWS Cloud
- In this lab, we will create 2 EC2 instances:
- 1 instance in a Public Subnet with a public IP
- 1 instance in a Private Subnet with a private IP only
Create an EC2 Instance in the Public Subnet
🔒 Instance Configuration
- Access the EC2 Dashboard
- Find and select the EC2 service in the AWS Management Console

- Launch a new instance
- Select Instances from the left navigation menu
- Click Launch instances

- Name the instance
- Under Name and tags, enter
EC2 Public
- Tags help organize and identify your resources

- Choose the Amazon Machine Image (AMI)
- Select the Quick Start tab
- Choose Amazon Linux 2023 (recommended for the latest features and security updates)
- Select the appropriate AMI version

- Configure the instance and key pair
- Choose an appropriate Instance type (for example, t3.micro for free tier)
- Click Create new key pair

- Create a new key pair
- Key pair name: Enter
aws-keypair (you can use any name)
- Key pair type: Select RSA
- Private key format: Select .pem (for Linux/Mac)
- Click Create key pair (the file will download automatically)
⚠️ Important: Save this key pair file securely. You cannot download it again after creation.

💡 Network Configuration
- Set up network settings
- VPC: Select the ASG VPC
- Subnet: Select Public Subnet 1
- Auto-assign public IP: Select Enable (required to access the internet)
- Firewall (Security Group): Select Select existing security group
- Choose Public subnet - SG (created in the previous section)
- Click Launch instance


- Confirm successful launch
- You should see a success message
- Click View all instances to see the new EC2 instance

⚠️ Check the Status
9. Wait for the instance to start up
- Wait about 2-5 minutes
- Monitor the Status check column
- The instance is ready when it shows 3/3 checks passed
- Instance state should be Running

Create an EC2 Instance in the Private Subnet
-
Launch a second instance
- In the EC2 console, select Instances
- Click Launch instances
-
Configure the private instance
- Name and tags: Enter
EC2 Private
- AMI: Select the Quick Start tab
- Choose Amazon Linux 2023 (same as the public instance for consistency)
- Select the appropriate AMI version


- Choose the instance type and key pair
- Choose an appropriate instance type (for example, t2.micro)
- Key pair name: Select
aws-keypair (use the key pair created earlier)

🔒 Network Configuration for the Private Instance
- Set up network settings for the private subnet
- VPC: Select the ASG VPC
- Subnet: Select Private Subnet 2
- Auto-assign public IP: Select Disable (private instances should not have a public IP)
- Firewall (Security Group): Select Select existing security group
- Choose Private subnet - SG
⚠️ Important: Make sure auto-assign public IP is disabled. If you cannot disable it, check the subnet’s auto-assign IP setting.


- Finish launching the instance
- Review your configuration
- Click Launch instance
- Click View all instances to see both instances

💡 Recording Instance Information
- Record the private instance details
- Wait about 2-5 minutes
- Monitor the Status check column
- The instance is ready when it shows 3/3 checks passed
- Instance state should be Running

💡 Architecture Summary:
- EC2 Public: In Public Subnet 1, has a public IP, can access the internet directly
- EC2 Private: In Private Subnet 2, has no public IP, will access the internet via a NAT Gateway