Create EC2 Server
Create EC2 Instances in Subnets
Access the AWS Management Console:
- Navigate to EC2
- Click on Instances

- In the EC2 interface:
- Select Instances from the left navigation panel
- Choose Launch instances

Provide a Name and tags for the instance:
- Enter
EC2 Public - Tags help organize and identify your resources
Choose the Amazon Machine Image (AMI):
- Select Quick Start tab
- Choose Amazon Linux 2023 (recommended for latest features and security updates)
- Select the appropriate AMI version

- Select an Instance type and create a key pair:
- Choose an appropriate instance type (e.g., t2.micro for free tier)
- Click Create a new key pair

- In the Create key pair interface:
- Specify the Key pair name:
aws-keypair (you can use any name) - Choose Key pair type: RSA
- Select Private key file format: .pem (for Linux/Mac) or .ppk (for PuTTY on Windows)
- Click Create key pair (the file will download automatically)
⚠️ Important: Save this key pair file securely. You cannot download it again after creation.

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

- Complete the instance creation:
- You should see a success message
- Click View all instances to see your new EC2 instance

- Wait for the instance to initialize:
- Wait approximately 2-5 minutes
- Monitor the Status check column
- Instance is ready when it shows 2/2 checks passed
- Instance state should be Running

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

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

- Configure the Network settings for private subnet:
- VPC: Select ASG VPC
- Subnet: Choose Private Subnet 2
- Auto-assign public IP: Disable (private instances should not have public IPs)
- Firewall (Security Group): Select Select existing security group
- Choose Private subnet - SG
⚠️ Important: Ensure auto-assign public IP is disabled. If you cannot disable it, verify the subnet’s auto-assign IP settings.

- Complete the instance creation:
- Review your configuration
- Click Launch instance
- Click View all instances to see both instances

- Record the private instance information:
- Select EC2 Private from the instances list
- Go to the Details tab
- Note down the Private IPv4 address (you’ll need this for SSH connection later)
- Verify that Public IPv4 address is empty (as expected for private subnet)

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