Post

03. EC2 Instance

03. EC2 Instance

EC2


Prerequisites


1. EC2 Instance

"aws-ec2-0"

EC2 is one of the most fundamental services in AWS. It provides Virtual servers in the cloud EC2 allows you to run applications on virtual machines without owning physical hardware.

Instead of:

  • Buying servers
  • Installing OS
  • Managing hardware

πŸ‘‰ You simply:

  • Launch an instance
  • Choose specifications
  • Start using it immediately

In EC2, a server is called an instance. It behaves like a real server, but it is virtual.

Each instance includes:

  • CPU (vCPU)
  • Memory (RAM)
  • Storage (EBS)
  • Network capability

2. How EC2 works

1
2
3
4
[ Physical Server (AWS Data Center) ]
 β”œβ”€β”€ EC2 Instance (User A)
 β”œβ”€β”€ EC2 Instance (User B)
 └── EC2 Instance (User C)

πŸ‘‰ Multiple users share the same hardware πŸ‘‰ Each instance is isolated

AMI is a template used to create instances.

It includes:

  • Operating System (Ubuntu, Amazon Linux, etc.)
  • Pre-installed software
  • Configuration

Think of it as A snapshot of a ready-to-run server

2-1. Basic steps

  1. Choose AMI (OS)
  2. Select instance type (CPU/RAM)
  3. Configure network (VPC, subnet)
  4. Add storage
  5. Configure security group
  6. Launch instance

2-2. Networking

EC2 does not exist alone.

It is placed inside:

  • VPC (Virtual Private Cloud)
  • Subnet (public / private)
TypeDescription
PublicAccessible from internet
PrivateInternal only
  • Security Group
  • Route Table
  • Internet Gateway

2-3. Security Group

Security Group acts as a firewall.

PortPurpose
22SSH
80HTTP
443HTTPS

πŸ‘‰ Only allowed traffic can enter

2-4. Key Pair (Login)

To access EC2:

  • Use SSH (Linux)
  • Use Key Pair (.pem)
1
ssh -i key.pem ubuntu@<public-ip>

πŸ‘‰ Password login is not used by default

2-5. Pricing Model

EC2 is pay-as-you-go:

  • Charged per usage time
  • Different pricing models:

    • On-Demand
    • Reserved
    • Spot
ScenarioRecommended
Testing / short-termOn-Demand
Batch / non-criticalSpot
Stable productionReserved / Savings Plan
Compliance requiredDedicated

3. How to create EC2

3-1. Search EC2

"aws-ec2-0"

3-2. Click Navigation pane β†’ β€œInstances”

"aws-ec2-1"

3-3. Click Button β†’ β€œLaunch instances”

"aws-ec2-2"

3-4. Step 1. Set Environments (Hardware)

"aws-ec2-3"

  1. Name and tags: EC2 name
  2. Application and OS Images (Amazon Machine Image): Select AMI
  3. Instance type: hardware configuration
TypeDescription
General PurposeBalanced CPU & memory
Compute OptimizedHigh CPU performance
Memory OptimizedLarge memory capacity
Accelerated ComputingGPU / FPGA based
  • More CPU β†’ faster computation
  • More memory β†’ better data handling
  • Higher network bandwidth β†’ faster communication
  • Higher EBS bandwidth β†’ faster storage I/O

3-5. Step 2. Set Environments (Security)

"aws-ec2-4"

  1. Key pair
  2. Network settings
    • VPC
    • Subnet
      • Public subnet
      • Private subnet
    • Availability Zone
      • Select AZ
    • Auto-assign public IP
      • Enable(Pulbic EC2)
      • Disable(Private EC2)
    • Firewall (security groups)
    • Inbound Security Group Rules

3-6. Step 3. Set Environments (Storage)

"aws-ec2-5"

  1. Storage

3-7. Launch Instance

"aws-ec2-6"

3-8. Confirm Instance

"aws-ec2-7"

3-9. Start/Stop/Reboot/Terminate Instance

"aws-ec2-8"

  • Automatically Management
    • Load Balancing
    • Target Groups
    • Auto Scaling Groups
  • Storage
    • Elastic Block Store(ELB)
    • Snapshots
  • Images
    • AMIs
  • Template

  • Networks
    • Elastic IPs
This post is licensed under CC BY 4.0 by the author.