AWS PrivateLink — VPC Endpoint Services

Publish exactly one service to other VPCs and other accounts — and nothing else. No peering, no internet gateway, no NAT, no route table edits. The two VPCs never become one network and the provider's CIDRs are never exposed, so overlapping address space stops being a problem at all.

Mở ra đúng một service cho các VPC và account khác — ngoài nó ra không lộ thêm thứ gì. Không cần peering, không internet gateway, không NAT, không phải sửa route table. Hai VPC không bao giờ nhập lại thành một mạng, và CIDR của bên provider thì bên kia không hề nhìn thấy — nên chuyện trùng dải địa chỉ cũng hết là vấn đề.

The shape is always the same: provider puts the app behind a Network Load Balancer and publishes it as an endpoint service; consumer creates an interface endpoint, which is an ENI with a private IP in their own subnets. That is the entire mechanism — and it is exactly what an interface endpoint to an AWS service is, too.

Hình dạng lúc nào cũng vậy: phía provider đặt ứng dụng sau một Network Load Balancer rồi publish thành endpoint service; phía consumer tạo một interface endpoint, thực chất là một ENI có private IP nằm trong subnet của chính họ. Cơ chế chỉ có thế — và interface endpoint trỏ tới service của AWS cũng chính là thứ này, không khác gì.

PrivateLink is the answer when… / not the right tool when…Khi nào PrivateLink là đáp án… / khi nào không phải

Reach for PrivateLinkChọn PrivateLink

  • You are the provider of a SaaS or an internal service and consumers live in other accounts you do not control. Thousands of them is fine — there is nothing to mesh.Bạn là bên cung cấp một SaaS hoặc một service nội bộ, còn người dùng nằm ở các account khác mà bạn không quản. Hàng nghìn consumer cũng không sao — chẳng phải đấu nối gì với nhau cả.
  • A shared service in a hub account — auth, licensing, a logging API — consumed by dozens of workload VPCs.Một service dùng chung đặt ở account hub — xác thực, cấp license, API nhận log — và hàng chục VPC workload khác gọi vào.
  • The consumer's CIDRs overlap yours, or you simply have no idea what they are. PrivateLink never routes to the provider's addresses, so it does not care.CIDR của consumer trùng với của bạn, hoặc đơn giản là bạn không biết họ dùng dải nào. PrivateLink không định tuyến tới địa chỉ của provider nên chuyện đó không liên quan.
  • Audit says "they may reach that one port and nothing else" — with PrivateLink there is nothing else to reach, by construction.Bên audit yêu cầu "chỉ được chạm tới đúng cổng đó, ngoài ra không gì khác" — với PrivateLink thì bản thân thiết kế đã không có gì khác để chạm tới.
  • On-premises over a private VIF needs private access to an AWS service: interface endpoints work from Direct Connect and VPN, a gateway endpoint does not.Từ on-prem đi qua private VIF mà cần truy cập private vào một service của AWS: interface endpoint dùng được từ Direct Connect và VPN, còn gateway endpoint thì không.

Not the right toolKhông phải chỗ dùng nó

  • You need general network reachability — many hosts, many ports, both directions. That is VPC Peering, not a published service.Bạn cần hai mạng thông nhau thật sự — nhiều host, nhiều cổng, cả hai chiều. Việc đó là của VPC Peering, không phải của một service đem publish.
  • Many VPCs must all reach each other. Meshing with PrivateLink means one endpoint service per service per direction — use Transit Gateway.Nhiều VPC phải liên lạc qua lại với nhau. Làm bằng PrivateLink thì mỗi service, mỗi chiều lại phải dựng một endpoint service — trường hợp này dùng Transit Gateway.
  • You only need S3 or DynamoDB from inside the VPC, nothing from on-premises and nothing cross-Region → a gateway endpoint is free and needs no ENI. See VPC Endpoints.Chỉ cần gọi S3 hoặc DynamoDB từ trong VPC, không có nhu cầu từ on-prem cũng không cross-Region → gateway endpoint miễn phí và chẳng cần ENI nào. Xem VPC Endpoints.
  • The service cannot sit behind an NLB. No Layer-4 entry point, no endpoint service — that is a hard requirement, not a preference.Service không thể đặt sau một NLB. Không có điểm vào tầng 4 thì không publish endpoint service được — đây là điều kiện bắt buộc, không phải khuyến nghị.
  • You want the provider to call the consumer. PrivateLink only flows consumer → provider; a callback needs its own path, its own endpoint service, or a queue.Bạn muốn provider chủ động gọi ngược về consumer. PrivateLink chỉ chạy một chiều consumer → provider; muốn callback thì phải có đường riêng, một endpoint service riêng, hoặc đi qua queue.

The shape — an NLB on one side, an ENI on the otherHình dạng — một bên là NLB, bên kia là ENI

Provider: application → NLB → published as a VPC endpoint service. Consumer: consumer app → endpoint ENI → PrivateLink → NLB → service. Nothing else is created, nothing else is routed, and the consumer never learns a single address from the provider's VPC. Phía provider: ứng dụng → NLB → đem publish thành VPC endpoint service. Phía consumer: app → ENI của endpoint → PrivateLink → NLB → service. Không sinh thêm thứ gì, không thêm route nào, và consumer không hề biết một địa chỉ nào bên trong VPC của provider.

A consumer VPC on the left holds a consumer application sending traffic to an interface endpoint, an ENI with the private IP 10.0.1.24 and a security group on it. From that ENI the traffic crosses a dashed AWS PrivateLink band in the middle and arrives at the provider VPC on the right, which is shaded to show the consumer cannot see inside it. There the traffic hits a Network Load Balancer acting as the layer four entry point, then the application service behind it. Both VPCs are labelled 10.0.0.0/16 to show that overlapping CIDRs do not matter, and the consumer VPC is annotated with no peering, no IGW, no NAT and no route table changes. one service published — not two networks joined AWS PrivateLink AWS private no internet Consumer VPC 10.0.0.0/16 consumer app endpoint ENI 10.0.1.24 security group no peering, no IGW, no NAT no route table changes SG on the ENI = who may connect Provider VPC 10.0.0.0/16 - overlap is fine NLB TCP/UDP - L4 app service published as a VPC endpoint service allowed principals = who may create one nothing else in here is visible consumer app -> endpoint ENI -> PrivateLink -> NLB -> service NLB across AZs + endpoint ENIs across AZs = fault tolerant the CIDR behind the NLB is never advertised to the consumer

Read the shading: everything on the right is opaque to the consumer. The only thing that exists on the consumer's side is an ENI with a private IP in their own subnet, so the "network" the consumer sees ends at that ENI. Both VPCs are 10.0.0.0/16 on purpose — with peering that diagram would not be buildable at all.

Hãy để ý phần tô đậm: mọi thứ bên phải đều mờ tịt với consumer. Bên phía consumer chỉ tồn tại đúng một ENI mang private IP nằm trong subnet của họ, nên "mạng" mà họ nhìn thấy dừng lại ngay tại cái ENI đó. Hai VPC đều để 10.0.0.0/16 là cố ý — nếu dùng peering thì hình này không dựng nổi.

Why it has to be an NLBTại sao bắt buộc phải là NLB PrivateLink hands raw TCP/UDP connections across to the provider, so the provider's service needs a Layer-4 entry point — and that is precisely what a Network Load Balancer is. Any HTTP-level routing lives behind the NLB, never in front of it. For virtual appliances — firewalls, inspection, IDS — a Gateway Load Balancer can front an endpoint service instead. PrivateLink chuyển thẳng các kết nối TCP/UDP sang phía provider, nên service bên đó phải có một điểm vào ở tầng 4 — và Network Load Balancer đúng là thứ đó. Muốn định tuyến theo HTTP thì phần đó nằm phía sau NLB, không bao giờ nằm trước. Riêng với các virtual appliance — firewall, thiết bị kiểm tra gói tin, IDS — thì Gateway Load Balancer có thể đứng trước endpoint service thay cho NLB.

Who is allowed to connect — two controls, two ownersAi được phép kết nối — hai lớp kiểm soát, hai người quản

Consumer · security groupConsumer · security group The consumer attaches an SG to the endpoint ENI. That is where you say which clients in the VPC may talk to the endpoint at all.Consumer gắn SG vào ENI của endpoint. Đây là chỗ quy định trong VPC thì client nào mới được nói chuyện với endpoint.
Provider · allowed principalsProvider · allowed principals The endpoint service lists the principals — accounts, users, roles — allowed to create an endpoint at all. Nobody is on that list by default.Endpoint service liệt kê các principal — account, user, role — được phép tạo endpoint. Mặc định danh sách này trống, chưa ai được cả.
Provider · acceptanceProvider · duyệt kết nối Even an allowed principal's connection sits pending until the provider accepts it, unless acceptance is set to automatic.Kể cả principal đã được cho phép, kết nối vẫn nằm ở trạng thái pending cho tới khi provider bấm duyệt — trừ khi đã bật chế độ tự động duyệt.
Both · availability zonesCả hai · availability zone Spread the NLB and the endpoint ENIs across AZs. Multi-AZ on one side only still leaves a single point of failure.Trải NLB và các ENI của endpoint ra nhiều AZ. Chỉ một bên multi-AZ thì vẫn còn nguyên một điểm chết.

PrivateLink vs VPC Peering — the distinction to memorisePrivateLink và VPC Peering — chỗ khác nhau phải thuộc

Peering connects networks: routes on both sides, reach into each other's subnets, CIDRs must not overlap, and it is symmetric. PrivateLink publishes a service: the consumer sees one endpoint and nothing else of the provider's network, it is one-directional (consumer → provider), and overlapping CIDRs do not matter. Peering là nối hai mạng lại với nhau: hai bên đều phải thêm route, với tới subnet của nhau, CIDR không được trùng, và quan hệ là đối xứng. PrivateLink là đem một service ra publish: consumer chỉ thấy đúng một endpoint, ngoài ra không thấy gì trong mạng của provider, luồng chỉ đi một chiều (consumer → provider), và CIDR trùng nhau cũng không sao.

The same pair of VPCs drawn twice. On the left, VPC peering: VPC A with CIDR 10.0.0.0/16 and VPC B with CIDR 10.1.0.0/16 are joined by a double-headed arrow, all subnets are reachable in both directions, route tables are required on both sides and the CIDRs must not overlap. On the right, PrivateLink: a consumer VPC and a shaded provider VPC both using 10.0.0.0/16 are joined by a single one-way arrow labelled endpoint, no route tables need touching, the identical CIDR does not matter, and only one published service is visible. peering: joins two networks VPC A 10.0.0.0/16 all subnets reachable VPC B 10.1.0.0/16 all subnets reachable peering route tables on BOTH sides CIDRs must not overlap symmetric: A sees B, B sees A anything routable is reachable PrivateLink: publishes a service Consumer 10.0.0.0/16 sees only the endpoint Provider 10.0.0.0/16 NLB + service rest hidden endpoint no route tables to touch same CIDR? does not matter one-way: consumer to provider one service, nothing else peering = network reachability - PrivateLink = service publication overlap kills peering; PrivateLink never sees the CIDR at all

Same two VPCs, two completely different relationships. On the left the arrow points both ways and the boxes are open to each other; on the right the arrow points one way and stops at an endpoint. If a question mentions overlapping CIDRs, or "must not have network access to the rest of the VPC", the left-hand picture is already ruled out.

Vẫn hai VPC đó nhưng là hai kiểu quan hệ hoàn toàn khác nhau. Bên trái mũi tên đi hai chiều, hai cái hộp mở toang ra với nhau; bên phải mũi tên chỉ đi một chiều và dừng lại ở endpoint. Đề bài mà nhắc tới CIDR trùng nhau, hoặc "không được có quyền truy cập mạng vào phần còn lại của VPC", thì hình bên trái coi như đã bị loại.

The sentence to keepCâu cần giữ trong đầu Peering connects networks. PrivateLink publishes a service. Everything else follows from that one line: peering needs routes on both sides and non-overlapping CIDRs because packets really are routed between the two VPCs; PrivateLink needs neither, because nothing is ever routed to the provider's address space — the consumer only ever talks to an ENI in its own subnet. If the requirement is "give the consumer network-level access", PrivateLink is the wrong answer; if it is "give the consumer this one service and nothing else", peering is. Peering là nối mạng. PrivateLink là publish service. Mọi thứ còn lại đều suy ra từ câu đó: peering cần route ở cả hai phía và CIDR không được trùng vì gói tin thật sự được định tuyến qua lại giữa hai VPC; PrivateLink không cần cả hai thứ đó, vì chẳng có gói tin nào được định tuyến sang dải địa chỉ của provider — consumer chỉ nói chuyện với một ENI nằm trong subnet của chính mình. Yêu cầu là "cho consumer truy cập ở mức mạng" thì chọn PrivateLink là sai; yêu cầu là "chỉ cho consumer đúng service này, không gì khác" thì chọn peering là sai.

An AWS-service interface endpoint is PrivateLinkInterface endpoint tới service của AWS chính là PrivateLink

Same machinery, different provider. When you create an interface endpoint for Secrets Manager, SSM or ECR, you are creating an ENI with a private IP and a security group in your subnet, and PrivateLink carries the traffic to a service fronted by a load balancer on the AWS side. AWS is simply the provider. Two things people memorise separately are one thing. Vẫn bộ máy đó, chỉ khác ai là provider. Khi bạn tạo interface endpoint cho Secrets Manager, SSM hay ECR, thứ bạn tạo ra là một ENI có private IP và security group trong subnet của mình, rồi PrivateLink đưa traffic tới một service nằm sau load balancer ở phía AWS. AWS đóng vai provider, chỉ vậy thôi. Hai khái niệm mà nhiều người học thuộc riêng rẽ thực ra là một.

AWS as providerAWS làm provider EC2 → VPCE ENI → PrivateLink → AWS service · this is an interface endpoint for SSM, ECR, KMS, Secrets Manager…đây chính là interface endpoint cho SSM, ECR, KMS, Secrets Manager…
You as providerBạn làm provider app → VPCE ENI → PrivateLink → NLB → service · identical picture; you supply the NLB that AWS supplies for its own serviceshình vẽ y hệt; chỉ khác là NLB do bạn dựng, còn service của AWS thì AWS tự lo
Private DNSPrivate DNS Makes the normal hostname resolve to the endpoint's private IPs inside the VPC, so no client code changes. Without it you must call the vpce-… name.Làm cho hostname bình thường phân giải ra private IP của endpoint ngay trong VPC, nên code client không phải sửa gì. Không bật thì phải gọi bằng tên vpce-….
Gateway endpoint — the odd one outGateway endpoint — kẻ khác biệt Not PrivateLink: a route table entry for S3/DynamoDB, no ENI, no SG, and unreachable from outside the VPC. Detail on VPC Endpoints.Không phải PrivateLink: chỉ là một dòng trong route table cho S3/DynamoDB, không ENI, không SG, và từ ngoài VPC thì không với tới được. Chi tiết ở VPC Endpoints.

PrivateLink for S3 with Direct ConnectPrivateLink cho S3 khi có Direct Connect

On-premises reaching S3 has two shapes. Over a public VIF the data centre talks to S3 directly on AWS public endpoints. Over a private VIF it lands in the VPC first, then goes out through PrivateLink and an interface endpoint to S3. Interface endpoints work from Direct Connect and VPN; a gateway endpoint does not — that is the whole reason to use one here. Từ on-prem đi tới S3 có hai kiểu. Đi qua public VIF thì data center nói chuyện thẳng với S3 qua các endpoint public của AWS. Đi qua private VIF thì traffic vào VPC trước, rồi từ đó ra S3 bằng PrivateLink và một interface endpoint. Interface endpoint dùng được từ Direct Connect và VPN, còn gateway endpoint thì không — đó chính là lý do duy nhất khiến ta chọn interface endpoint ở đây.

Two ways an on-premises data centre reaches Amazon S3 across the same Direct Connect. On the left, the on-prem data centre with a client application on 192.168.0.0/16 connects to a Direct Connect physical link, which carries two virtual interfaces. The top path is a public VIF: it goes straight to Amazon S3's public endpoint, targeting AWS public IP ranges, with no VPC and no endpoint involved, still riding the Direct Connect rather than the public Internet. The bottom path is a private VIF: it lands in a consumer VPC on 10.0.0.0/16, hits an S3 interface endpoint — an ENI with private IP 10.0.1.24, a security group and an endpoint policy — and from there crosses AWS PrivateLink to reach Amazon S3 privately. A gateway endpoint could not be reached from on-premises at all, which is why the interface endpoint is used. two ways on-prem reaches S3 over the same Direct Connect On-prem DC 192.168.0.0/16 client app Direct Connect physical link public VIF Amazon S3 public endpoint public IP ranges · no VPC · no endpoint still over the DX, not the public Internet private VIF Consumer VPC 10.0.0.0/16 S3 interface endpoint ENI · private IP 10.0.1.24 security group endpoint policy AWS PrivateLink Amazon S3 reached privately a gateway endpoint is unreachable from on-prem

Same S3, same Direct Connect, two virtual interfaces. The public VIF reaches S3's public endpoint with nothing built in a VPC — private wiring, public destination. The private VIF is the one the exam wants when "must not touch a public endpoint" appears: it lands in the VPC, passes an interface endpoint's security group and endpoint policy, and rides PrivateLink to S3. The one path that does not exist here is a gateway endpoint — it is a route table entry, unreachable from outside the VPC.

Vẫn S3 đó, vẫn Direct Connect đó, chỉ khác ở hai virtual interface. Public VIF đi tới endpoint public của S3 mà không cần dựng gì trong VPC — đường đi private, đích đến public. Private VIF mới là thứ đề thi muốn khi xuất hiện câu "không được chạm endpoint public": traffic vào VPC, đi qua security group và endpoint policy của interface endpoint, rồi theo PrivateLink tới S3. Đường duy nhất không tồn tại ở đây là gateway endpoint — nó chỉ là một dòng route table, từ ngoài VPC không với tới được.

Pick between the twoChọn giữa hai kiểu Public VIF → S3 is the shorter path and needs nothing in the VPC, but it targets AWS public endpoints. Private VIF → VPC → interface endpoint → S3 keeps everything on private addressing, puts a security group and an endpoint policy in the path, and is the answer whenever the requirement says the traffic must not touch a public endpoint. The gateway endpoint is not an option from on-premises at all. Public VIF → S3 là đường ngắn hơn, không cần dựng gì trong VPC, nhưng đích đến vẫn là endpoint public của AWS. Private VIF → VPC → interface endpoint → S3 thì mọi thứ chạy trên địa chỉ private, lại chèn thêm được security group và endpoint policy vào đường đi — đề bài nào nói traffic không được chạm tới endpoint public thì chọn kiểu này. Còn gateway endpoint thì từ on-prem hoàn toàn không dùng được.

Cross-Region connectivityKết nối cross-Region

An interface endpoint does not have to point at something in its own Region. EC2 in us-east-1 → interface endpoint → S3 in eu-west-1 works, and so does an endpoint in us-east-1 reaching the NLB that fronts your own service in ap-east-1. One endpoint in the consumer's VPC, the service wherever it happens to live. Interface endpoint không bắt buộc phải trỏ tới thứ nằm cùng Region với nó. EC2 ở us-east-1 → interface endpoint → S3 ở eu-west-1 là chạy được, và một endpoint ở us-east-1 gọi tới NLB đang đứng trước service của bạn ở ap-east-1 cũng vậy. Consumer chỉ cần một endpoint trong VPC của mình, còn service nằm ở Region nào cũng được.

Things that catch you outNhững chỗ dễ sập bẫy

  • A gateway endpoint is not PrivateLink. It is a route table entry, it creates no ENI, it takes no security group, and it is unreachable from on-premises, from a peered VPC or from another Region. The moment the requirement leaves the VPC, the answer becomes an interface endpoint. Gateway endpoint không phải PrivateLink. Nó chỉ là một dòng trong route table, không sinh ENI, không gắn được security group, và từ on-prem, từ VPC đã peering hay từ Region khác đều không với tới được. Hễ yêu cầu vượt ra ngoài phạm vi VPC là đáp án chuyển sang interface endpoint.
  • PrivateLink is one-directional. The consumer initiates, the provider answers on that connection — and that is all. If the design needs the provider to call back into the consumer, that is a second, separate path: its own endpoint service, or a queue, or an event bus. PrivateLink chỉ chạy một chiều. Consumer mở kết nối, provider trả lời trên chính kết nối đó — hết. Nếu thiết kế cần provider chủ động gọi ngược về consumer thì đó là một đường thứ hai hoàn toàn tách biệt: một endpoint service riêng, hoặc đi qua queue, hoặc qua event bus.
  • Two security groups sit in the path, not one. The client's SG must allow outbound to the endpoint, and the endpoint ENI's SG must allow inbound from the client. A connection that times out with everything else configured is almost always the second one, because people forget the endpoint has an SG at all. Trên đường đi có tới hai security group chứ không phải một. SG của client phải cho phép đi ra tới endpoint, và SG của ENI endpoint phải cho phép đi vào từ client. Cấu hình đủ hết mà kết nối vẫn treo rồi timeout thì gần như luôn là do cái thứ hai — vì người ta hay quên rằng bản thân endpoint cũng có SG.
  • Nobody can connect until the provider says so. An endpoint service starts with an empty allowed principals list, and by default new connections stay pending acceptance. "The consumer created the endpoint but it never became available" is this, not a networking fault. Chưa được provider gật đầu thì không ai kết nối được. Endpoint service khi mới tạo có danh sách allowed principals rỗng, và mặc định kết nối mới sẽ nằm chờ ở trạng thái pending acceptance. Tình huống "consumer tạo endpoint rồi mà mãi không lên available" là do cái này, chứ không phải lỗi mạng.
  • Do not authorise consumers by source IP. Traffic arrives at the provider's targets through the NLB, so the client's real address is not what you get. Identify the caller properly — the endpoint ID carried by Proxy Protocol v2, mTLS, or an application-level credential. Đừng phân quyền consumer dựa trên IP nguồn. Traffic tới target của provider là đi qua NLB, nên địa chỉ thật của client không phải thứ bạn nhìn thấy. Hãy định danh người gọi một cách đàng hoàng — dùng endpoint ID mà Proxy Protocol v2 mang theo, dùng mTLS, hoặc một credential ở tầng ứng dụng.

Exam reflexesPhản xạ khi thi

The question says…Đề nói… AnswerĐáp án
"Expose one internal service to thousands of VPCs, including third-party accounts""Mở một service nội bộ cho hàng nghìn VPC, kể cả account của bên thứ ba" PrivateLink: NLB + VPC endpoint service; each consumer creates an interface endpointPrivateLink: NLB + VPC endpoint service; mỗi consumer tự tạo interface endpoint
"The two VPCs have overlapping CIDRs""Hai VPC có CIDR trùng nhau" PrivateLink — peering and Transit Gateway are both out; nothing is routed to the provider's CIDRPrivateLink — peering và Transit Gateway đều loại; có gói nào định tuyến sang CIDR của provider đâu
"The consumer must not reach anything else in our VPC""Consumer không được chạm tới bất cứ thứ gì khác trong VPC của mình" PrivateLink. Peering would hand over route-level reach to the whole CIDRPrivateLink. Dùng peering là trao luôn quyền với tới cả dải CIDR
"Restrict which consumers may connect to the published service""Giới hạn consumer nào được kết nối tới service đã publish" Security group on the endpoint ENI + allowed principals and acceptance on the endpoint serviceSecurity group gắn vào ENI của endpoint + allowed principals và bước duyệt ở endpoint service
"The private service access must be fault tolerant""Đường truy cập private tới service phải chịu được lỗi" NLB in multiple AZs and endpoint ENIs in multiple AZs — both sides, or it is notNLB trải nhiều AZ và ENI của endpoint cũng trải nhiều AZ — thiếu một bên là chưa đạt
"On-premises over Direct Connect must reach S3 without the public internet""Từ on-prem qua Direct Connect phải tới được S3 mà không đi qua internet công cộng" Private VIF → VPC → PrivateLink interface endpoint → S3. A gateway endpoint cannot be used from on-premisesPrivate VIF → VPC → interface endpoint qua PrivateLink → S3. Gateway endpoint không dùng được từ on-prem
"An app in us-east-1 must privately reach a service in another Region""App ở us-east-1 cần truy cập private tới service ở Region khác" Cross-Region interface endpoint — it can target S3 or the NLB fronting your service in the other RegionInterface endpoint cross-Region — trỏ được sang S3 hoặc sang NLB đang đứng trước service của bạn ở Region kia