[DevOps] AWS VPC (1)

maketheworldwiseยท2021๋…„ 8์›” 29์ผ
0
post-custom-banner

๐Ÿง Today I Learned (TIL)

  • AWS VPC ๊ธฐ๋Šฅ
  • AWS VPC ์‹ค์Šต

AWS VPC ๊ธฐ๋Šฅ

AWS VPC ๊ธฐ๋Šฅ ํŠน์ง•

  • ๊ณ„์ • ์ƒ์„ฑ ์‹œ default VPC ์ƒ์„ฑ๋จ
  • EC2, RDS, S3 ๋“ฑ์˜ ์„œ๋น„์Šค์—์„œ ํ™œ์šฉ ๊ฐ€๋Šฅ
  • ์„œ๋ธŒ๋„ท ๊ตฌ์„ฑ
  • ๋ณด์•ˆ ์„ค์ • (IP block, inbound / outbound ์„ค์ •)
  • VPC Peering
  • IP ๋Œ€์—ญ ์ง€์ •
  • VPC๋Š” ํ•˜๋‚˜์˜ ๋ฆฌ์ „์—๋งŒ ์ข…์†

AWS VPC ๊ตฌ์„ฑ ์š”์†Œ

  • Availability Zone
  • Subnet (CIDR)
  • Internet Gateway
  • NACL (Network Access Control List), Security Group
  • Route Table
  • NAT Instance (Network Address Translation), Nat Gateway
  • VPC Endpoint

[์ถœ์ฒ˜: https://crishantha.medium.com/handling-vpc-endpoints-ac192b0361a5]

Availability Zone

๊ฐ ๋ฆฌ์ „๋ณ„๋กœ ์—ฌ๋Ÿฌ AZ๊ฐ€ ์กด์žฌํ•˜๋Š”๋ฐ ์ด๋Š” ๋ฌผ๋ฆฌ์ ์œผ๋กœ ๋ถ„๋ฆฌ๋˜์–ด ์ž‡๋Š” ์ธํ”„๋ผ๊ฐ€ ๋ชจ์—ฌ ์žˆ๋Š” ๋ฐ์ดํ„ฐ ์„ผํ„ฐ๋ฅผ ์˜๋ฏธํ•œ๋‹ค. ๊ฐ AZ๋Š” ์ผ์ • ๊ฑฐ๋ฆฌ ์ด์ƒ ๋–จ์–ด์ ธ ์žˆ์œผ๋ฉฐ ํ•˜๋‚˜์˜ ๋ฆฌ์ „์€ 2๊ฐœ ์ด์ƒ์˜ AZ๋กœ ๊ตฌ์„ฑ๋˜์–ด์žˆ๋‹ค. ๊ฐ ๊ณ„์ •์˜ AZ๋Š” ๋‹ค๋ฅธ ๊ณ„์ •์˜ AZ์™€ ๋‹ค๋ฅธ ์•„์ด๋””๋ฅผ ๋ถ€์—ฌ๋ฐ›๋Š”๋‹ค.

Subnet (CIDR)

VPC์˜ ํ•˜์œ„ ๋‹จ์œ„๋กœ ํ•˜๋‚˜์˜ AZ์—์„œ๋งŒ ์ƒ์„ฑ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ํ•˜๋‚˜์˜ AZ๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ Subnet์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. ์ฃผ๋กœ Public Subnet๊ณผ Private Subnet์œผ๋กœ ๋‚˜๋‰˜๋Š”๋ฐ ์ด๋Š” ์ธํ„ฐ๋„ท์— ์ ‘๊ทผ ๊ฐ€๋Šฅ ์—ฌ๋ถ€์— ๋”ฐ๋ผ ๋‚˜๋‰œ๋‹ค.

Private Subnet ๋‚ด์—๋Š” ์ฃผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ๊ฐ™์€ ๋ณด์•ˆ์ ์œผ๋กœ ์ค‘์š”ํ•œ ๊ฒฉ๋ฆฌ๋œ ์„œ๋น„์Šค๋“ค์ด ์œ„์น˜ํ•œ๋‹ค. ํ•˜์ง€๋งŒ ์ด๋Ÿฌํ•œ ์„œ๋น„์Šค๋“ค์€ ์™ธ๋ถ€์—์„œ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ๋‹ค์šด๋ฐ›๊ฑฐ๋‚˜ ์—…๋ฐ์ดํŠธ๋ฅผ ํ•˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ธํ„ฐ๋„ท๊ณผ์˜ ํ†ต์‹ ์ด ๋ฐ˜๋“œ์‹œ ํ•„์š”ํ•ด์ง€๊ฒŒ ๋œ๋‹ค. ๋”ฐ๋ผ์„œ Private Subnet์ด ์™ธ๋ถ€์™€ ํ†ต์‹ ์ด ํ•„์š”ํ•  ๊ฒฝ์šฐ Public Subnet์„ ํ†ตํ•ด ์šฐํšŒํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•˜๋‹ค. (ํ•˜๋‚˜์˜ VPC ๋‚ด๋ถ€์˜ ์„œ๋ธŒ๋„ท ๊ฐ„์˜ ํ†ต์‹ ์ด ๊ฐ€๋Šฅํ•˜๊ธฐ ๋•Œ๋ฌธ)

Internet Gateway (IGW)

์‰ฝ๊ฒŒ ๋งํ•ด ์ธํ„ฐ๋„ท์œผ๋กœ ๋‚˜๊ฐ€๋Š” ํ†ต๋กœ๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. ๋‹จ, Private Subnet์€ IGW๋กœ ์ด๋™ํ•˜์ง€ ์•Š๋Š”๋‹ค.

NACL, Security Group

๋ณด์•ˆ์— ํ•ด๋‹นํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ฉฐ NACL์€ Stateless, Security Group์€ Statefulํ•˜๊ฒŒ ๋™์ž‘ํ•œ๋‹ค. Access Block์€ NACL์—์„œ๋งŒ ๊ฐ€๋Šฅํ•˜๋‹ค.

Route Table

ํŠธ๋ž˜ํ”ฝ์„ ์•ˆ๋‚ดํ•ด์ฃผ๋Š” ํ…Œ์ด๋ธ”์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. (VPC๋ฅผ ์ƒ์„ฑํ•˜๋ฉด ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋จ)

NAT Instance, NAT Gateway

์œ„์—์„œ ์–ธ๊ธ‰ํ–ˆ๋“ฏ์ด Private Subnet์ด Public Subnet์„ ์šฐํšŒํ•˜์—ฌ ์™ธ๋ถ€์™€ ํ†ต์‹ ์ด ํ•„์š”ํ•  ๊ฒฝ์šฐ NAT ์ธ์Šคํ„ด์Šค ํ˜น์€ NAT Gateway๋ฅผ ํ†ตํ•ด์„œ ๊ฐ€๋Šฅํ•˜๋‹ค. ๋‹จ, Public Subnet์— ์œ„์น˜ํ•ด์•ผ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

NAT ์ธ์Šคํ„ด์Šค๋Š” ํ•˜๋‚˜์˜ EC2๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋˜๋ฉฐ NAT Gateway๋Š” AWS์—์„œ ์ œ๊ณตํ•˜๋Š” ํŠนํ™”๋œ ์„œ๋น„์Šค๋กœ ์‚ฌ์šฉ๋ฐฉ๋ฒ•์€ ๊ต‰์žฅํžˆ ๊ฐ„๋‹จํ•˜๋‹ค.

Bastion Host๋Š” ์™ธ๋ถ€์— ์žˆ๋Š” ์‚ฌ์šฉ์ž(์ฃผ๋กœ ๊ฐœ๋ฐœ์ž ํ˜น์€ ๊ด€๋ฆฌ์ž)๊ฐ€ Private Subnet์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋‚ด์šฉ์œผ๋กœ NAT ์ธ์Šคํ„ด์Šค์™€ NAT Gateway์™€ ์œ ์‚ฌํ•œ ๊ฐœ๋…์ด๋‹ค. Public Subnet์— ์œ„์น˜ํ•˜๋Š” EC2๋ผ๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค.

NAT ์ธ์Šคํ„ด์Šค์™€ NAT Gateway๋Š” Private Subnet์—์„œ ์™ธ๋ถ€๋กœ ๊ฐ€๋Š” ๋ฐฉํ–ฅ์ด๋ผ๋ฉด Bastion Host๋Š” ์™ธ๋ถ€์—์„œ Private Subnet์œผ๋กœ ๊ฐ€๋Š” ๋ฐฉํ–ฅ์˜ ๊ฐœ๋…์ด๋‹ค.

VPC Endpoint

VPC Endpoint๋Š” ์„œ๋น„์Šค์— ๋น„๊ณต๊ฐœ๋กœ ์—ฐ๊ฒฐํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. Public IP ์ฃผ์†Œ๊ฐ€ ํ•„์š”์—†๋‹ค๋Š” ํŠน์ง•์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค.

VPC Endpoint๋Š” AWS์˜ ์—ฌ๋Ÿฌ ์„œ๋น„์Šค๋“ค๊ณผ VPC๋ฅผ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ์ค‘๊ฐ„ ๋งค๊ฐœ์ฒด์ด๋‹ค. AWS์—์„œ VPC ์™ธ๋ถ€๋กœ ํŠธ๋ž˜ํ”ฝ์ด ๋‚˜๊ฐ€์ง€ ์•Š๊ณ  AWS์˜ ์—ฌ๋Ÿฌ ์„œ๋น„์Šค๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ๋” ๋งŒ๋“ค์–ด์ฃผ๋Š” ์„œ๋น„์Šค์ด๋‹ค. Private Subnet์€ ๊ฒฉ๋ฆฌ๋œ ๊ณต๊ฐ„์ž„์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ  Private Subnet์— ์œ„์น˜ํ•œ S3, DynamoDB, Athena, RDS ๋“ฑ์„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค์ด๋‹ค.

  • Interface Endpoint
    Private Subnet ๋‚ด์—์„œ Private IP๋ฅผ ๋งŒ๋“ค์–ด ์„œ๋น„์Šค๋กœ ์—ฐ๊ฒฐํ•ด์ค€๋‹ค. (SQS, SNS, Kinesis, Sagemaker ๋“ฑ ์ง€์›)

[์ถœ์ฒ˜: https://medium.com/@netscylla/aws-and-vpc-endpoints-privatelinks-faad1e2290ca]
  • Gateway Endpoint
    Route Table์—์„œ ๊ฒฝ๋กœ์˜ ๋Œ€์ƒ์œผ๋กœ ์ง€์ •ํ•˜์—ฌ ์‚ฌ์šฉํ•œ๋‹ค. (S3, DynamoDB ์ง€์›)

๐Ÿ“š ์ฐธ๊ณ 

  • ์—†์Œ
profile
์„ธ์ƒ์„ ํ˜„๋ช…ํ•˜๊ฒŒ ์ด๋Œ์–ด๊ฐˆ ๋‚˜์˜ ์„ฑ์žฅ ์ผ๊ธฐ ๐Ÿ““
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€