본문 바로가기
프로그래밍

AWS EC2 Fundamentals

by AandBB 2025. 3. 31.

EC2 = Elastic Compute Cloud = Infrastructure as a Service

  • Renting virtual machines
  • ...

bootstrap our instances using an EC2 User Data script

bootstrapping means launching commands when a machine starts

That scrip is only run once at the instance first start


runch first EC2 instance(virtual server) running Amazon Linux

runch web server on the EC2 instance

web server running on my instance

chosse a base image for EC2 instance which is operating system

key pair to log into instance -> necessary if we use SSH utility

Security Group : control the traffic from and to our instance

EC2AWS가 제공하는 클라우드 컴퓨팅 서비스 중 하나로, 사용자가 필요할 때 언제든지 가상 서버를 생성/삭제할 수 있도록 제공합니다.

EC2 Instance는 EC2에서 생성된 가상 서버 한 대입니다.

EC2 서비스를 사용하여 EC2 인스턴스를 생성하고, 인스턴스 위에서 웹 서버를 운영한다.


Instance Types

  • General Purpose : Great for a diversity of workloads such as web servers or code repository. Balance between compute, memory, networking
  • Compute Optimized
  • Memory Optimized
  • Storage Optimized

  • 22 = SSH - log into Linux instance
  • 21 = FTP - upload files into file share
  • 22 = SFTP - upload files using SSH
  • 80 = HTTP - access unsecured websites
  • 443 = HTTPS - access secured websites
  • 3389 = RDP(Remote Desktop Protocol) - log into Windows instance

ssh -i .\MyKeyPair.pem ec2-user@3.26.196.216


3월 28일

4+10+6+10+9

use IAM roles for your EC2 instances


dedicated instances : have own instance on own hardware

dedicated hosts : get access to physical server itself. gives visibility to the lower level hardware

saving plans : pay a certain amount per hour for certain period


Amazon VPC IP Address Manager : monitor all IP adresses


  • can only cancel spot requests that are open, active or disalbed
  • cancelling a spot request does not terminate instances
  • must first cancel a spot reqeust, and then terminate the associated Spot Instances (그렇지 않으면 다시 spot request로 돌아가 instance를 생성해버린다)
  • Spot Fleets : set of Spot Instances + (optional) On-Demand Instances
  • spot fleets will launch instances from the pool that has the lowest price
  • diversified : distributed across all pools
  • priceCapacityOptimized : pools with highest capacity available, then select the pool with the lowest price

Spot Fleets allow us to automatically request Spot Instances with the lowest price (Spot Request knows exactly the type of instance you want)


EC2 Reserved Instances can be reserved for 1 or 3 years only.

  • Memory Optimized EC2 instances are great for workloads requiring large data sets in memory.
  • a critical application that uses an in-memory database
  • Storage Optimized EC2 instances are great for workloads requiring high, sequential read/write access to large data sets on local storage.
  • handle this high-frequency OLTP database