Create EC2 Server

Create EC2 Instances in Subnets

  1. Access the AWS Management Console:

    • Navigate to EC2
    • Click on Instances

Create VPC

  1. In the EC2 interface:
    • Select Instances from the left navigation panel
    • Choose Launch instances

Create VPC

  1. Provide a Name and tags for the instance:

    • Enter EC2 Public
    • Tags help organize and identify your resources
  2. 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

Create VPC

  1. 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

Create VPC

  1. 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.

Create VPC

  1. 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

Create VPC

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

Create VPC

  1. 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 VPC

Create EC2 in a Private Subnet

  1. Launch another EC2 instance:

    • In the EC2 interface, select Instances
    • Choose Launch instances
  2. 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

Create VPC

  1. 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)

Create VPC

  1. 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.

Create VPC

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

Create VPC

  1. 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)

Create VPC

💡 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