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

  1. Access the EC2 Dashboard
    • Find and select the EC2 service in the AWS Management Console

Create VPC

  1. Launch a new instance
    • Select Instances from the left navigation menu
    • Click Launch instances

Create VPC

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

Create VPC

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

Create VPC

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

Create VPC

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

Create VPC

💡 Network Configuration

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

Create VPC

Create VPC

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

Create VPC

⚠️ 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 VPC

Create an EC2 Instance in the Private Subnet

  1. Launch a second instance

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

Create VPC

Create VPC

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

Create VPC

🔒 Network Configuration for the Private Instance

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

Create VPC

Create VPC

  1. Finish launching the instance
    • Review your configuration
    • Click Launch instance
    • Click View all instances to see both instances

Create VPC

💡 Recording Instance Information

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

Create VPC

💡 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