VPC (Virtual Private Cloud)

VPC (Virtual Private Cloud)

1. VPC κ°œμš”

1.1 VPCλž€?

VPCλŠ” ν΄λΌμš°λ“œ λ‚΄μ—μ„œ λ…Όλ¦¬μ μœΌλ‘œ 격리된 가상 λ„€νŠΈμ›Œν¬μž…λ‹ˆλ‹€.

핡심 κ°œλ…: - 자체 IP μ£Όμ†Œ λ²”μœ„ μ •μ˜ - μ„œλΈŒλ„·μœΌλ‘œ λΆ„ν•  - λΌμš°νŒ… ν…Œμ΄λΈ”λ‘œ νŠΈλž˜ν”½ μ œμ–΄ - λ³΄μ•ˆ κ·Έλ£Ή/λ°©ν™”λ²½μœΌλ‘œ μ ‘κ·Ό ν†΅μ œ

1.2 AWS vs GCP VPC 차이

ν•­λͺ© AWS VPC GCP VPC
λ²”μœ„ 리전 λ‹¨μœ„ κΈ€λ‘œλ²Œ
μ„œλΈŒλ„· λ²”μœ„ κ°€μš© μ˜μ—­ (AZ) 리전
κΈ°λ³Έ VPC 리전당 1개 ν”„λ‘œμ νŠΈλ‹Ή 1개 (default)
피어링 리전 κ°„ κ°€λŠ₯ κΈ€λ‘œλ²Œ μžλ™
IP λ²”μœ„ 생성 μ‹œ κ³ μ • μ„œλΈŒλ„· μΆ”κ°€ κ°€λŠ₯
AWS VPC ꡬ쑰:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  VPC (리전: ap-northeast-2)                                  β”‚
β”‚  CIDR: 10.0.0.0/16                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚  β”‚ Subnet-a (AZ-a)     β”‚  β”‚ Subnet-b (AZ-b)     β”‚            β”‚
β”‚  β”‚ 10.0.1.0/24         β”‚  β”‚ 10.0.2.0/24         β”‚            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

GCP VPC ꡬ쑰:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  VPC (κΈ€λ‘œλ²Œ)                                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚
β”‚  β”‚ Subnet-asia         β”‚  β”‚ Subnet-us           β”‚            β”‚
β”‚  β”‚ (asia-northeast3)   β”‚  β”‚ (us-central1)       β”‚            β”‚
β”‚  β”‚ 10.0.1.0/24         β”‚  β”‚ 10.0.2.0/24         β”‚            β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. μ„œλΈŒλ„·

2.1 퍼블릭 vs 프라이빗 μ„œλΈŒλ„·

μœ ν˜• 인터넷 μ ‘κ·Ό μš©λ„
퍼블릭 직접 κ°€λŠ₯ μ›Ή μ„œλ²„, Bastion
프라이빗 NAT ν†΅ν•΄μ„œλ§Œ μ• ν”Œλ¦¬μΌ€μ΄μ…˜, DB

2.2 AWS μ„œλΈŒλ„· 생성

# 1. VPC 생성
aws ec2 create-vpc \
    --cidr-block 10.0.0.0/16 \
    --tag-specifications 'ResourceType=vpc,Tags=[{Key=Name,Value=MyVPC}]'

# 2. 퍼블릭 μ„œλΈŒλ„· 생성
aws ec2 create-subnet \
    --vpc-id vpc-12345678 \
    --cidr-block 10.0.1.0/24 \
    --availability-zone ap-northeast-2a \
    --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=Public-Subnet-1}]'

# 3. 프라이빗 μ„œλΈŒλ„· 생성
aws ec2 create-subnet \
    --vpc-id vpc-12345678 \
    --cidr-block 10.0.10.0/24 \
    --availability-zone ap-northeast-2a \
    --tag-specifications 'ResourceType=subnet,Tags=[{Key=Name,Value=Private-Subnet-1}]'

# 4. 퍼블릭 IP μžλ™ ν• λ‹Ή (퍼블릭 μ„œλΈŒλ„·)
aws ec2 modify-subnet-attribute \
    --subnet-id subnet-public \
    --map-public-ip-on-launch

2.3 GCP μ„œλΈŒλ„· 생성

# 1. μ»€μŠ€ν…€ λͺ¨λ“œ VPC 생성
gcloud compute networks create my-vpc \
    --subnet-mode=custom

# 2. μ„œλΈŒλ„· 생성 (μ„œμšΈ)
gcloud compute networks subnets create subnet-asia \
    --network=my-vpc \
    --region=asia-northeast3 \
    --range=10.0.1.0/24

# 3. μ„œλΈŒλ„· 생성 (λ―Έκ΅­)
gcloud compute networks subnets create subnet-us \
    --network=my-vpc \
    --region=us-central1 \
    --range=10.0.2.0/24

# 4. 프라이빗 Google μ•‘μ„ΈμŠ€ ν™œμ„±ν™”
gcloud compute networks subnets update subnet-asia \
    --region=asia-northeast3 \
    --enable-private-ip-google-access

3. 인터넷 κ²Œμ΄νŠΈμ›¨μ΄

3.1 AWS Internet Gateway

# 1. IGW 생성
aws ec2 create-internet-gateway \
    --tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Name,Value=MyIGW}]'

# 2. VPC에 μ—°κ²°
aws ec2 attach-internet-gateway \
    --internet-gateway-id igw-12345678 \
    --vpc-id vpc-12345678

# 3. λΌμš°νŒ… ν…Œμ΄λΈ”μ— 경둜 μΆ”κ°€
aws ec2 create-route \
    --route-table-id rtb-12345678 \
    --destination-cidr-block 0.0.0.0/0 \
    --gateway-id igw-12345678

# 4. 퍼블릭 μ„œλΈŒλ„·μ— λΌμš°νŒ… ν…Œμ΄λΈ” μ—°κ²°
aws ec2 associate-route-table \
    --route-table-id rtb-12345678 \
    --subnet-id subnet-public

3.2 GCP 인터넷 μ ‘κ·Ό

GCPλŠ” λ³„λ„μ˜ 인터넷 κ²Œμ΄νŠΈμ›¨μ΄ 없이 μ™ΈλΆ€ IPκ°€ 있으면 인터넷 접근이 κ°€λŠ₯ν•©λ‹ˆλ‹€.

# μ™ΈλΆ€ IP ν• λ‹Ή (μΈμŠ€ν„΄μŠ€ 생성 μ‹œ)
gcloud compute instances create my-instance \
    --zone=asia-northeast3-a \
    --network=my-vpc \
    --subnet=subnet-asia \
    --address=EXTERNAL_IP  # λ˜λŠ” μƒλž΅ν•˜λ©΄ μž„μ‹œ IP ν• λ‹Ή

# 정적 IP μ˜ˆμ•½
gcloud compute addresses create my-static-ip \
    --region=asia-northeast3

4. NAT Gateway

프라이빗 μ„œλΈŒλ„·μ˜ μΈμŠ€ν„΄μŠ€κ°€ 인터넷에 μ ‘κ·Όν•  수 μžˆλ„λ‘ ν•©λ‹ˆλ‹€.

4.1 AWS NAT Gateway

# 1. Elastic IP ν• λ‹Ή
aws ec2 allocate-address --domain vpc

# 2. NAT Gateway 생성 (퍼블릭 μ„œλΈŒλ„·μ—)
aws ec2 create-nat-gateway \
    --subnet-id subnet-public \
    --allocation-id eipalloc-12345678 \
    --tag-specifications 'ResourceType=natgateway,Tags=[{Key=Name,Value=MyNAT}]'

# 3. 프라이빗 λΌμš°νŒ… ν…Œμ΄λΈ”μ— 경둜 μΆ”κ°€
aws ec2 create-route \
    --route-table-id rtb-private \
    --destination-cidr-block 0.0.0.0/0 \
    --nat-gateway-id nat-12345678

# 4. 프라이빗 μ„œλΈŒλ„·μ— λΌμš°νŒ… ν…Œμ΄λΈ” μ—°κ²°
aws ec2 associate-route-table \
    --route-table-id rtb-private \
    --subnet-id subnet-private

4.2 GCP Cloud NAT

# 1. Cloud Router 생성
gcloud compute routers create my-router \
    --network=my-vpc \
    --region=asia-northeast3

# 2. Cloud NAT 생성
gcloud compute routers nats create my-nat \
    --router=my-router \
    --region=asia-northeast3 \
    --auto-allocate-nat-external-ips \
    --nat-all-subnet-ip-ranges

5. λ³΄μ•ˆ κ·Έλ£Ή / λ°©ν™”λ²½

5.1 AWS Security Groups

λ³΄μ•ˆ 그룹은 μΈμŠ€ν„΄μŠ€ 레벨의 μƒνƒœ μ €μž₯(stateful) λ°©ν™”λ²½μž…λ‹ˆλ‹€.

# λ³΄μ•ˆ κ·Έλ£Ή 생성
aws ec2 create-security-group \
    --group-name web-sg \
    --description "Web server security group" \
    --vpc-id vpc-12345678

# μΈλ°”μš΄λ“œ κ·œμΉ™ μΆ”κ°€
aws ec2 authorize-security-group-ingress \
    --group-id sg-12345678 \
    --protocol tcp \
    --port 80 \
    --cidr 0.0.0.0/0

aws ec2 authorize-security-group-ingress \
    --group-id sg-12345678 \
    --protocol tcp \
    --port 443 \
    --cidr 0.0.0.0/0

aws ec2 authorize-security-group-ingress \
    --group-id sg-12345678 \
    --protocol tcp \
    --port 22 \
    --cidr 203.0.113.0/24  # νŠΉμ • IP만 ν—ˆμš©

# λ‹€λ₯Έ λ³΄μ•ˆ κ·Έλ£Ήμ—μ„œ μ˜€λŠ” νŠΈλž˜ν”½ ν—ˆμš©
aws ec2 authorize-security-group-ingress \
    --group-id sg-db \
    --protocol tcp \
    --port 3306 \
    --source-group sg-web

# κ·œμΉ™ 쑰회
aws ec2 describe-security-groups --group-ids sg-12345678

5.2 GCP Firewall Rules

GCP λ°©ν™”λ²½ κ·œμΉ™μ€ VPC λ ˆλ²¨μ—μ„œ μž‘λ™ν•˜λ©° νƒœκ·Έ λ˜λŠ” μ„œλΉ„μŠ€ κ³„μ •μœΌλ‘œ λŒ€μƒμ„ μ§€μ •ν•©λ‹ˆλ‹€.

# HTTP νŠΈλž˜ν”½ ν—ˆμš© (νƒœκ·Έ 기반)
gcloud compute firewall-rules create allow-http \
    --network=my-vpc \
    --allow=tcp:80,tcp:443 \
    --target-tags=http-server \
    --source-ranges=0.0.0.0/0

# SSH ν—ˆμš© (νŠΉμ • IP)
gcloud compute firewall-rules create allow-ssh \
    --network=my-vpc \
    --allow=tcp:22 \
    --target-tags=ssh-server \
    --source-ranges=203.0.113.0/24

# λ‚΄λΆ€ 톡신 ν—ˆμš©
gcloud compute firewall-rules create allow-internal \
    --network=my-vpc \
    --allow=tcp,udp,icmp \
    --source-ranges=10.0.0.0/8

# κ·œμΉ™ λͺ©λ‘ 쑰회
gcloud compute firewall-rules list --filter="network:my-vpc"

# κ·œμΉ™ μ‚­μ œ
gcloud compute firewall-rules delete allow-http

5.3 AWS NACL (Network ACL)

NACL은 μ„œλΈŒλ„· 레벨의 μƒνƒœ λΉ„μ €μž₯(stateless) λ°©ν™”λ²½μž…λ‹ˆλ‹€.

# NACL 생성
aws ec2 create-network-acl \
    --vpc-id vpc-12345678 \
    --tag-specifications 'ResourceType=network-acl,Tags=[{Key=Name,Value=MyNACL}]'

# μΈλ°”μš΄λ“œ κ·œμΉ™ μΆ”κ°€ (κ·œμΉ™ 번호둜 μš°μ„ μˆœμœ„)
aws ec2 create-network-acl-entry \
    --network-acl-id acl-12345678 \
    --ingress \
    --rule-number 100 \
    --protocol tcp \
    --port-range From=80,To=80 \
    --cidr-block 0.0.0.0/0 \
    --rule-action allow

# μ•„μ›ƒλ°”μš΄λ“œ κ·œμΉ™λ„ ν•„μš” (stateless)
aws ec2 create-network-acl-entry \
    --network-acl-id acl-12345678 \
    --egress \
    --rule-number 100 \
    --protocol tcp \
    --port-range From=1024,To=65535 \
    --cidr-block 0.0.0.0/0 \
    --rule-action allow

6. VPC 피어링

6.1 AWS VPC Peering

# 1. 피어링 μ—°κ²° μš”μ²­
aws ec2 create-vpc-peering-connection \
    --vpc-id vpc-requester \
    --peer-vpc-id vpc-accepter \
    --peer-region ap-northeast-1  # λ‹€λ₯Έ 리전인 경우

# 2. 피어링 μ—°κ²° 수락
aws ec2 accept-vpc-peering-connection \
    --vpc-peering-connection-id pcx-12345678

# 3. μ–‘μͺ½ VPC의 λΌμš°νŒ… ν…Œμ΄λΈ”μ— 경둜 μΆ”κ°€
# Requester VPC
aws ec2 create-route \
    --route-table-id rtb-requester \
    --destination-cidr-block 10.1.0.0/16 \
    --vpc-peering-connection-id pcx-12345678

# Accepter VPC
aws ec2 create-route \
    --route-table-id rtb-accepter \
    --destination-cidr-block 10.0.0.0/16 \
    --vpc-peering-connection-id pcx-12345678

6.2 GCP VPC Peering

# 1. 첫 번째 VPCμ—μ„œ 피어링 생성
gcloud compute networks peerings create peer-vpc1-to-vpc2 \
    --network=vpc1 \
    --peer-network=vpc2

# 2. 두 번째 VPCμ—μ„œ 피어링 생성 (μ–‘μͺ½ ν•„μš”)
gcloud compute networks peerings create peer-vpc2-to-vpc1 \
    --network=vpc2 \
    --peer-network=vpc1

# λΌμš°νŒ…μ€ μžλ™μœΌλ‘œ 좔가됨

7. 프라이빗 μ—”λ“œν¬μΈνŠΈ

인터넷을 κ±°μΉ˜μ§€ μ•Šκ³  AWS/GCP μ„œλΉ„μŠ€μ— μ ‘κ·Όν•©λ‹ˆλ‹€.

7.1 AWS VPC Endpoints

Gateway Endpoint (S3, DynamoDB):

aws ec2 create-vpc-endpoint \
    --vpc-id vpc-12345678 \
    --service-name com.amazonaws.ap-northeast-2.s3 \
    --route-table-ids rtb-12345678

Interface Endpoint (λ‹€λ₯Έ μ„œλΉ„μŠ€):

aws ec2 create-vpc-endpoint \
    --vpc-id vpc-12345678 \
    --service-name com.amazonaws.ap-northeast-2.secretsmanager \
    --vpc-endpoint-type Interface \
    --subnet-ids subnet-12345678 \
    --security-group-ids sg-12345678

7.2 GCP Private Service Connect

# Private Google Access ν™œμ„±ν™”
gcloud compute networks subnets update subnet-asia \
    --region=asia-northeast3 \
    --enable-private-ip-google-access

# Private Service Connect μ—”λ“œν¬μΈνŠΈ
gcloud compute addresses create psc-endpoint \
    --region=asia-northeast3 \
    --subnet=subnet-asia \
    --purpose=PRIVATE_SERVICE_CONNECT

8. 일반적인 VPC μ•„ν‚€ν…μ²˜

8.1 3ν‹°μ–΄ μ•„ν‚€ν…μ²˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  VPC (10.0.0.0/16)                                           β”‚
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Public Subnets (10.0.1.0/24, 10.0.2.0/24)               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚β”‚
β”‚  β”‚  β”‚    ALB      β”‚  β”‚   Bastion   β”‚                        β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                           ↓                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Private Subnets - App (10.0.10.0/24, 10.0.11.0/24)      β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚β”‚
β”‚  β”‚  β”‚   App-1     β”‚  β”‚   App-2     β”‚                        β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                           ↓                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Private Subnets - DB (10.0.20.0/24, 10.0.21.0/24)       β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                        β”‚β”‚
β”‚  β”‚  β”‚  DB Primary β”‚  β”‚  DB Standby β”‚                        β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                         β”‚
β”‚  β”‚     IGW      β”‚  β”‚   NAT GW     β”‚                         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

8.2 AWS VPC μ˜ˆμ‹œ (Terraform)

# VPC
resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_hostnames = true
  tags = { Name = "main-vpc" }
}

# Public Subnets
resource "aws_subnet" "public" {
  count             = 2
  vpc_id            = aws_vpc.main.id
  cidr_block        = "10.0.${count.index + 1}.0/24"
  availability_zone = data.aws_availability_zones.available.names[count.index]
  map_public_ip_on_launch = true
  tags = { Name = "public-${count.index + 1}" }
}

# Private Subnets
resource "aws_subnet" "private" {
  count             = 2
  vpc_id            = aws_vpc.main.id
  cidr_block        = "10.0.${count.index + 10}.0/24"
  availability_zone = data.aws_availability_zones.available.names[count.index]
  tags = { Name = "private-${count.index + 1}" }
}

# Internet Gateway
resource "aws_internet_gateway" "main" {
  vpc_id = aws_vpc.main.id
}

# NAT Gateway
resource "aws_nat_gateway" "main" {
  allocation_id = aws_eip.nat.id
  subnet_id     = aws_subnet.public[0].id
}

9. 문제 ν•΄κ²°

9.1 μ—°κ²° 문제 체크리슀트

β–‘ λ³΄μ•ˆ κ·Έλ£Ή μΈλ°”μš΄λ“œ κ·œμΉ™ 확인
β–‘ NACL κ·œμΉ™ 확인 (AWS)
β–‘ λ°©ν™”λ²½ κ·œμΉ™ 확인 (GCP)
β–‘ λΌμš°νŒ… ν…Œμ΄λΈ” 확인
β–‘ 인터넷 κ²Œμ΄νŠΈμ›¨μ΄ μ—°κ²° 확인
β–‘ NAT κ²Œμ΄νŠΈμ›¨μ΄ μƒνƒœ 확인
β–‘ μΈμŠ€ν„΄μŠ€μ— 퍼블릭 IP μžˆλŠ”μ§€ 확인
β–‘ VPC 피어링 λΌμš°νŒ… 확인

9.2 디버깅 λͺ…λ Ήμ–΄

AWS:

# VPC Flow Logs ν™œμ„±ν™”
aws ec2 create-flow-logs \
    --resource-type VPC \
    --resource-ids vpc-12345678 \
    --traffic-type ALL \
    --log-destination-type cloud-watch-logs \
    --log-group-name vpc-flow-logs

# Reachability Analyzer
aws ec2 create-network-insights-path \
    --source i-source \
    --destination i-destination \
    --destination-port 80 \
    --protocol tcp

GCP:

# VPC Flow Logs ν™œμ„±ν™”
gcloud compute networks subnets update subnet-asia \
    --region=asia-northeast3 \
    --enable-flow-logs

# Connectivity Tests
gcloud network-management connectivity-tests create my-test \
    --source-instance=projects/PROJECT/zones/ZONE/instances/source \
    --destination-instance=projects/PROJECT/zones/ZONE/instances/dest \
    --destination-port=80 \
    --protocol=TCP

10. λ‹€μŒ 단계


참고 자료

to navigate between lessons