Configure AWS PrivateLink to establish private connectivity between two separate AWS accounts using a VPC Endpoint Service, Network Load Balancer (NLB), and Interface VPC Endpoint.
Table of Contents
- Introduction
- Architecture Overview
- Prerequisites
- Implementation
- Conclusion
1. Introduction
In this tutorial, we will configure an AWS VPC Endpoint Service using a Network Load Balancer (NLB) to privately expose an application hosted in a service provider VPC to consumers in another VPC.
The architecture consists of two VPCs: a provider VPC hosting an application behind a Network Load Balancer and a consumer VPC accessing the service through an Interface VPC Endpoint.
Using AWS PrivateLink provides secure private connectivity between VPCs without requiring an internet gateway, NAT Gateway, or VPC peering. It also allows service providers to expose services to other AWS accounts without exposing them to the public internet.
2. Architecture Overview
Download the editable here → Click here to download

- VPC Consumer (Company B): Hosts the client EC2 instance that needs to access the service provided by Company A.
- Public Subnet: Hosts the Bastion Host for SSH administration of the client EC2 through AWS
PrivateLink. - Interface VPC Endpoint: Creates private network interfaces (ENIs) in the consumer VPC to establish connectivity to the provider’s Endpoint Service.
- VPC Provider (Company A): Hosts the application or service that will be shared privately with consumers.
- VPC Endpoint Service: Exposes the provider’s service through AWS PrivateLink and allows authorized consumers to connect.
- Network Load Balancer (NLB): Receives incoming traffic from PrivateLink and distributes it to the backend service instances across Availability Zones.
- Private Subnets: Host the NLB and backend EC2 service instances across two Availability Zones for high availability.
- Endpoint Connection Acceptance: The provider can manually approve connection requests from authorized consumers or enable automatic acceptance.
3. Prerequisites
- Two active AWS account
- Basic Linux
- Basic understanding of AWS networking
- A prebuilt AMI with
httpdinstalled.

4. Implementation
Part1: Configuration the Service Provider (Company A)
-
Create a VPC with four private subnets
This implementation assumes you have already created a VPC with four private subnets across two Availability Zones.
If you haven’t created your VPC and subnets yet, refer to: [Building a Secure AWS VPC with Public and Private Subnets] .
-
Launch an EC2 instance
Launch an EC2 instance in
provider-vpc.- Subnet:
provider-sub-private-02 - AMI: Prebuilt AMI with HTTPD installed.
-
Security Group:
Inbound: HTTP (TCP 80) from the vpc CIDR.
Since this lab uses an NLB without a security group, allow traffic from the vpc CIDRs rather than referencing an NLB security group.
- Subnet:
-
Create a Network Load Balancer
Create a Target Group
-
Go to EC2 → Target Groups → Create target group.
-
Configure:
- Target type: Instances
- Target group name:
provider-endpoint-tg - Protocol: HTTP
- Port: 80
- VPC:
provider-vpc
-
Under Register targets, select the EC2 instance created earlier, set
port to 80 and click Include as pending below.
-
Review and create a target group.
Create the Network Load Balancer
-
Go to EC2 → Load Balancers → Create load balancer.
-
Choose Network Load Balancer.
-
Configure:
- Name:
provider-endpoint-nlb - Scheme: Internal
- Name:
-
Under Network mapping:
- VPC:
provider-vpc - Select the two Availability Zones shown in your architecture.
- Select the corresponding private subnets.
- VPC:
- Security Groups: None (for this lab).
-
Listener and routing:
- Protocol: TCP
- Port: 80
- Forward to:
provider-endpoint-tg
-
Click Create load balaner.
-
Go to EC2 → Target Groups → Create target group.
-
Create a VPC Endpoint Service
-
Go to VPC → Endpoint services → Create endpoint service.
-
Configure:
- Name:
endpoint-svc-01 - Load balancer type: Network
- Available load balancer:
provider-endpoint-nlb
- Name:
-
Enable Acceptance required.
-
Supported IP address types: IPv4 and click Create.
Allow the Consumer AWS Account
- Open the newly created Endpoint Service.
- Find Allowed principals.
- Click Allow principals.
-
Enter the Consumer AWS Account ARN:
arn:aws:iam::CONSUMER_ACCOUNT_ID:root -
Click Allow principal
-
Go to VPC → Endpoint services → Create endpoint service.
Part2: Configure the Service Consumer (Company B)
-
Create a VPC with three subnets
This implementation assumes you have already created a VPC with:
- One public subnet.
- Two private subnets across two Availability Zones.
If you haven’t created your VPC and subnets yet, refer to: [Building a Secure AWS VPC with Public and Private Subnets].
-
Launch a Bastion Host
Launch an EC2 instance in the public subnet.
- Name:
bastion-host -
Security Group:
-
Inbound: SSH (TCP 22) from your public IP.
-
Inbound: SSH (TCP 22) from your public IP.
- Name:
-
Launch a Client EC2 instance
Launch an EC2 instance in a private subnet.
- Name:
client-01 - Subnet: Consumer private subnet.
-
Security Group:
-
Inbound: SSH (TCP 22) from the vpc CIDR.
-
Inbound: SSH (TCP 22) from the vpc CIDR.
- Name:
-
Create an Interface VPC Endpoint
Create a Security Group
Create a security group for the Interface Endpoint.
Inbound: HTTP (TCP 80) from the VPC CIDR range.
Create the Endpoint
-
Go to VPC → Endpoints → Create endpoint.
-
Name:
vpc-endpoint-01and under Service category, choose Endpoint services that use NLBs and GWLBs.
-
Enter the Endpoint Service name provided by Company A and Click
Verify service.
To get the service name of the Company A
-
Network settings:
-
VPC:
consumer-vpc.
-
VPC:
-
Select Subnets
Select the two private subnets that correspond to the Availability Zone IDs supported by the provider’s Endpoint Service.
For this lab, use:
use1-az4use1-az6
Important: Both AZ IDs must have corresponding subnets in the Consumer VPC. The provider’s NLB must also have those AZ IDs enabled.
-
Configure Security Group
Select the Endpoint security group created earlier and click Create endpoint.
After creation, the endpoint should show: Pending acceptance
-
Go to VPC → Endpoints → Create endpoint.
-
Accept the Endpoint Connection
Switch back to Company A (Provider Account).
- Go to VPC → Endpoint services.
- Select your Endpoint Service.
- Open Endpoint connections.
- Select the pending connection request.
- Choose Actions → Accept endpoint connection request.
Once accepted, the endpoint connection status should become
Available. -
Test the PrivateLink Connection
Connect to the Bastion Host
SSH into the Bastion Host, then SSH from the Bastion Host to
client-01using its private IP.Test the Endpoint Service
- Go to Company B → VPC → Endpoints.
- Select
vpc-endpoint-01. - Copy the endpoint-specific DNS name.
- From
client-01, execute:
curl http://<VPC-ENDPOINT-DNS-NAME>
Expected result:
You should receive the HTTP response from the Apache web server running on the EC2 instance in Company A.
5. Conclusion
We have successfully configured an AWS VPC Endpoint Service using a Network Load Balancer (NLB) to allow an EC2 instance in a separate a AWS account to privately access a service hosted in the provider VPC through AWS PrivateLink.
This architecture is useful when organizations need to expose applications or API privately to other AWS accounts without requiring VPC Peering, VPN, or Transit Gateway, improving security, simplifying network connectivity, and supporting cross-account service integration.