Sub topic 3
Creating an Interface Endpoint in a Consumer VPC
Assume you know CIDR blocks, subnets, route tables, security groups, network ACLs, AWS CLI, and Network Load Balancers.
Create the interface endpoint
AWS PrivateLink lets a consumer VPC access one provider service without routing to the provider VPC. An interface endpoint is a set of elastic network interfaces (ENIs) in consumer subnets. Applications connect to these ENIs through private DNS.
aws ec2 create-vpc-endpoint \
--vpc-endpoint-type Interface \
--vpc-id vpc-0aaa1111bbb22222 \
--service-name com.amazonaws.vpce.us-east-1.vpce-svc-0123456789abcdef0 \
--subnet-ids subnet-0aaa1111 subnet-0bbb2222 \
--security-group-ids sg-0123456789abcdef0
aws ec2 accept-vpc-endpoint-connections \
--service-id vpce-svc-0123456789abcdef0 \
--vpc-endpoint-ids vpce-0123456789abcdef0The provider must allow the consumer account and accept the request when the endpoint service requires acceptance.
DNS, security groups, and access
Use the endpoint-specific DNS name, or enable a provider-configured private DNS name after domain ownership verification. The endpoint's security group must allow inbound traffic from application security groups on the service port. The provider's Network Load Balancer and targets must also allow that traffic.
Access has several controls:
- The provider's endpoint service permissions allow specific principals.
- Manual acceptance controls connection approval.
- The endpoint security group controls traffic to endpoint ENIs.
- The load balancer and target security groups control provider-side traffic.
Combine PrivateLink with Transit Gateway
Use Transit Gateway when workloads need network-level access between many VPCs. Use PrivateLink when consumers should reach only a selected service. A hub VPC can attach to a transit gateway for shared routing while publishing selected services through PrivateLink.
Advanced design concerns
For centralized inspection, attach an appliance VPC to the transit gateway and enable appliance mode. This keeps a flow's traffic on the same appliance path when required by stateful firewalls. Configure route tables carefully so inspection is not bypassed.
To connect Regions, create a transit gateway peering attachment, accept it in the other Region, and add routes in both transit gateway route tables. Peering routes are static; they do not automatically propagate.
Overlapping VPC CIDRs prevent reliable network-level routing because the same destination can mean different VPCs. Redesign address ranges where possible. PrivateLink often remains usable because it exposes a service endpoint instead of requiring reachability to the provider CIDR.
Troubleshooting and cost
Use Reachability Analyzer to test paths between an instance and an endpoint ENI. Check endpoint state, DNS resolution, security groups, NACLs, route tables, provider acceptance, and target health. VPC Flow Logs can show rejected or missing traffic.
Transit Gateway charges for attachments and processed data. Interface endpoints charge hourly per endpoint Availability Zone and for processed data. Check the current regional pricing before choosing many endpoints or centralized routing.
Exercise
Should you use Transit Gateway or PrivateLink when a consumer needs only one provider API?
Show answer
Use PrivateLink. It exposes the API without granting network-level access to the provider VPC.