iamjjanga blog

Aws Vpc Endpoints Review

Intro

최근 업무를 진행하면서 Production VPC에서는 S3 Endpoints(Gateway)가 다른 엔지니어분의 작업으로 해당 설정이 유효하게 설정되었지만, Dev VPC는 누락된 부분이 있어서 다시 리서치하는 의미에서 이 글을 작성하게 되었다.

Endpoints

AWS에서 S3는 다양한 환경에서 사용한다.

여기서 S3를 참조할때 네트워크 트래픽에 대한 부분을 많이 간과해서 사용하는 경우에 적은 Call수에는 차이가 나지 않을 수 있지만 잦고 다량의 Call이 발생할때는 무시할 수 없는 비용이다.

참조한 AWS Blog 포스팅에서는 해당 비용에 대한 최적화에 대해서 소개한다.

Reduce Cost and Increase Security with Amazon VPC Endpoints | Amazon Web Services

Type of Endpoints

  1. Gateway

    • ex) S3와 DynamoDB에 액세스하는 구성을 제공
    • 정책(Policy)는 AWS IAM을 통해서 설정 및 제어된다.
      • 특정 DynamoDB 테이블에 액세스를 제한 하는 정책을 만들 수도 있음
    • Route Table 설정 필요

    alt text

  2. Gateway LoadBalancer

    • 기존에 설정된 Gateway LoadBalancer의 트래픽을 Gateway LoadBalancer Endpoints로 라우팅해 네트워크 또는 보안 서비스로 라우팅 가능
    • 방화벽, 침입 탐지 및 예방, 심층 패킷 검사 시스템과 같은 가상장치를 배포, 확장 관리 가능하게함.
  3. Interface

    • AWS PrivateLink를 통해 제공되는 서비스에 연결할 수 있도록 도움
    • 정책은 AWS IAM을 통해서 제어되고, Security Group으로 방화벽을 설정

    alt text

  4. Centeralize VPC Endpoints

    1. 생략

(Hands-On) Gateway로 S3 Endpoints 설정

[Test Environment]

NAT 사용 확인 하기

먼저 traceroute 명령어가 필요해서 설치를 진행한다.

1apt update -y
2apt install traceroute -y

abc Bucket에 대한 경로를 조회

1traceroute -T -p 443 abc.s3.ap-northeast-2.amazonaws.com

각 옵션의 의미는 다음과 같다. ( 참고 )

1# 결과
2traceroute to abc.s3.ap-northeast-2.amazonaws.com (3.5.187.12), 30 hops max, 60 byte packets
3 1  ip-10-10-139-32.ap-northeast-2.compute.internal (10.10.139.32)  0.367 ms  0.332 ms  0.294 ms
4 2  * * *
5 3  3.5.187.12 (3.5.187.12)  2.420 ms  2.270 ms  1.610 ms

S3 Endpoints 생성

AWS Console에서 생성이 가능하지만 Hands-On에 가깝게 캡쳐보다는 CLI로 작성해보았다.

1# vpc-endpoints Gateway type으로 생성 (s3)
2export REGION=ap-northeast-2
3aws ec2 create-vpc-endpoint \
4    --vpc-id vpc-xxxxxxxx \
5    --service-name com.amazonaws.${REGION}.s3 \
6    --route-table-ids rtb-xxxxxxxx \
7    --endpoint-type Gateway \
8    --tag-specifications "ResourceType=vpc-endpoint,Tags=[{Key=Name,Value=xxxx-endpoint}]"

생성에 필요한 리소스 정보는 다음과 같다.

CLI로 생성한 결과는 다음과 같다. Route Table을 지정하면 자동으로 Rule로 등록된다.

 1## 생성결과
 2{
 3    "VpcEndpoint": {
 4        "VpcEndpointId": "vpce-xxxx",
 5        "VpcEndpointType": "Gateway",
 6        "VpcId": "vpc-xxxx",
 7        "ServiceName": "com.amazonaws.ap-northeast-2.s3",
 8        "State": "available",
 9        "PolicyDocument": "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"*\",\"Resource\":\"*\"}]}",
10        "RouteTableIds": [
11            "rtb-xxxx"
12        ],
13        "SubnetIds": [],
14        "Groups": [],
15        "PrivateDnsEnabled": false,
16        "RequesterManaged": false,
17        "NetworkInterfaceIds": [],
18        "DnsEntries": [],
19        "CreationTimestamp": "2025-11-04T13:56:17+00:00",
20        "Tags": [
21            {
22                "Key": "Name",
23                "Value": "xxx-endpoint-gateway-private"
24            }
25        ],
26        "OwnerId": "123412341234"
27    }
28}

NAT를 사용하지 않는 것을 확인

다시 traceroute 명령어로 S3에 접근해보면 리턴되는 IP에 NAT가 찍히지 않는것을 확인할 수 있다.

1traceroute to abc.s3.ap-northeast-2.amazonaws.com (3.5.189.33), 30 hops max, 60 byte packets
2 1  3.5.189.33 (3.5.189.33)  1.037 ms  1.033 ms  1.013 ms

Ref

#Aws #Hands-On