시작 전에, Budget을 설정해두고 하면 좋다. 이를 통해 실제 과금된 금액, 예상되는 과금금액을 기준으로 알림을 미리 받을 수 있다.
EC2
- EC2는 Elastic Compute Cloud의 약자이고, Infrastructure as a Service다.
- EC2로 주로 다음과 같이 구성된다.

- OS는 Linux, Windows, Mac OS를 지원한다.
EC2 User Data
- EC2 User data script를 통해 인스턴스를 bootstrap할 수 있다.
- bootstrapping은 machine이 시작될때의 시작 명령들을 의미하고, 인스턴스가 시작될 때만 딱 한번 수행된다.
- EC2 User Data는 여러 boot task들을 자동화하는데 쓰인다.
- EC2 User Data Script는 root user로 동작한다.

EC2 인스턴스를 시작할 때 Amazon Machine Image (AMI)를 고를 수 있다.
EC2 인스턴스를 stop했다가 다시 start하면 public IP가 변경된다.(private IP는 변경X)
EC2 Instance Type
Amazon EC2는 각 사용 사례에 맞게 최적화된 다양한 인스턴스 유형을 제공한다. 이때 name convention은 다음과 같다.
m5.2xlarge일 때
- m: instance class
- 5: generation
- 2xlarge: size within the instance class
EC2 유형은 목적에 따라 구분할 수 있다.
- General Purpose: T, M
- Compute Optimized: C
- Memory Optimized: R, X, Z
- Storage Optimized: I,D,H
가격 비교에 좋은 사이트: https://instances.vantage.sh/
Security Group
Secutiry Group은 둘러싼 방화벽으로 보면 된다.
- Security Group은 allow 규칙들만 포함한다.
- Security Group rule들은 IP나 Security Group으로 정의할 수 있다.
- 모든 inbound traffic은 blocked가 기본이고, 모든 outbound traffic은 authorised가 기본이다.
<꿀팁>
- application is not accessible (time out) => security group issue
- application gives a “connection refused“ error => application error 또는 not launched
Referencing other security groups Diagram

대표적인 Port들
- 22 = SSH(Secure Shell) - log into a Linux instance
- 80 = HTTP - access unsecured websites
- 443 = HTTPS = access secured websites
- 21 = FTP(File Transfer Protocol) - upload files into a file share
- 22 = SFTP(Secure File Transfer Protocol) - upload files using SSH
- 3389 = RDP(Remote Desktop Protocol) - log into a Windows instance
::/0은 IPv6 전부, 0.0.0.0/0은 IPv4 전부를 의미한다.
SSH
EC2에 SSH 접속 방법은 다음과 같다.

이때, EC2 Instance Connect는 Amazon Linux 2에서만 바로 사용 가능하다.
EC2안에서 절재절대 access key를 입력하면 안된다. 다른 user가 접속해서 확인 가능.
-> 대신 iam role을 EC2에서 이용하면 된다.
EC2 Instance Purchasing Options
EC2 구매에 다음과 같은 선택지들이 있다.
- On Demand
- Reserved
- Savings Plans
- Spot Instances: 가장 가성비 좋다
- Dedicated Hosts: pysical server를 통으로 빌려서 가장 비싸다
- Dedicated Instances
- Capacity Reservations
Spot Fleets
- Spot Fleets는 set of Spot Instances + (optional) On-Demand Instances