Sub topic 10
Publishing an endpoint service from a Network Load Balancer
This chapter assumes you know what a Network Load Balancer (NLB) is, how target groups work, and how IAM principals are written as ARNs. You should also know the PrivateLink provider/consumer model from the previous chapter. Here you act as the provider. You publish an existing NLB so that other accounts can reach it privately.
The working model
An endpoint service is a named wrapper around one or more NLBs (or Gateway Load Balancers). Consumers never see your VPC, your subnets, or your instances. They see a service name and connect to it through an interface endpoint in their own VPC.
The provider controls three things:
- Which load balancer backs the service. The NLB must exist before you create the service.
- Who may request a connection. This is the allowed principals list.
- Whether you approve each request. This is the acceptance setting.
Create the service
Run these commands in the provider account. The first command creates the service. The second command allows one consumer account to request a connection.
aws ec2 create-vpc-endpoint-service-configuration \
--network-load-balancer-arns arn:aws:elasticloadbalancing:us-east-1:111122223333:loadbalancer/net/my-svc/0123456789abcdef \
--acceptance-required
aws ec2 modify-vpc-endpoint-service-permissions \
--service-id vpce-svc-0123456789abcdef0 \
--add-allowed-principals arn:aws:iam::444455556666:rootThe output of the first command includes a ServiceId and a ServiceName. Use the ServiceId in later provider commands. Give the ServiceName to the consumer. It looks like com.amazonaws.vpce.us-east-1.vpce-svc-0123456789abcdef0.
--acceptance-required means every connection stays in pendingAcceptance until you accept it. Without this flag, any allowed principal connects immediately.
Decisions that matter
| Setting | What it does | Typical choice |
|---|---|---|
| Acceptance required | Provider approves each connection | On for external customers, off inside one organization |
| Allowed principals | IAM ARNs that may request a connection | Specific account roots, not `*` |
| Availability Zones | The service is reachable only in AZs where the NLB has a subnet | Enable the NLB in every AZ consumers use |
The AZ rule causes many surprises. A consumer can place an endpoint only in AZs that the service supports. If the NLB covers two AZs, the consumer cannot add a third.
Common errors
- Connection stuck in
pendingAcceptance. The provider has not runaccept-vpc-endpoint-connections. The consumer cannot fix this. UnauthorizedOperationor an invalid service error for the consumer. The consumer's principal is not in the allowed list.- Targets unhealthy. The service accepts connections but traffic fails. Check the NLB target group health and the target security groups. If client IP preservation is on, the targets see the consumer's source address, so the target security group must allow it.
- Wrong Region. By default, a service is available only in its own Region.
Exercise
A consumer in account 444455556666 creates an interface endpoint to your service, and the endpoint stays in pendingAcceptance. Which setting caused this, and which command resolves it?
Show answer
The service was created with --acceptance-required. The provider resolves it by running aws ec2 accept-vpc-endpoint-connections with the service ID and the endpoint ID.