Sub topic 12
DNS names, security groups, and who may connect
This chapter assumes you can read a security group rule and know how Route 53 private hosted zones resolve names inside a VPC. It also assumes you have already created an endpoint service and an interface endpoint, as in the previous two chapters.
Which DNS name does the client use?
An interface endpoint gets several names automatically:
- A regional name such as
vpce-0123-abcd.vpce-svc-0123456789abcdef0.us-east-1.vpce.amazonaws.com. - One zonal name per Availability Zone, with the zone ID added to the front.
Both resolve to the private IP addresses of the endpoint's network interfaces. Clients can use these names with no extra setup, but the names are long and tied to one endpoint.
A provider can instead publish a private DNS name, such as api.example.com. The provider must prove it owns the domain by adding a TXT record that AWS generates. After that, consumers who enable private DNS on their endpoint can use api.example.com directly. AWS creates a hidden private hosted zone in the consumer VPC, so the name resolves to the endpoint's private IPs.
# Provider: set the private DNS name and start domain verification
aws ec2 modify-vpc-endpoint-service-configuration \
--service-id vpce-svc-0123456789abcdef0 \
--private-dns-name api.example.com
aws ec2 start-vpc-endpoint-service-private-dns-verification \
--service-id vpce-svc-0123456789abcdef0
# Consumer: use the private DNS name
aws ec2 modify-vpc-endpoint \
--vpc-endpoint-id vpce-0123456789abcdef0 \
--private-dns-enabledThe consumer VPC needs both enableDnsSupport and enableDnsHostnames turned on. If either is off, private DNS does not work.
Security groups on the endpoint
The endpoint's network interfaces carry security groups that you choose when you create the endpoint. These groups act as the consumer's firewall. They must allow inbound traffic from your clients on the port of the NLB listener.
aws ec2 authorize-security-group-ingress \
--group-id sg-0123456789abcdef0 \
--protocol tcp --port 443 \
--source-group sg-0fedcba9876543210Referencing the client's security group is better than a CIDR range because it keeps working when instances change addresses. On the provider side, the NLB sees traffic that comes from addresses in the provider's own VPC, not the consumer's CIDR. This is why overlapping CIDRs are not a problem for PrivateLink. If the provider needs to identify the caller, it can turn on Proxy Protocol v2, which includes the endpoint ID.
Who may connect
Several controls apply in order:
| Control | Set by | Effect |
|---|---|---|
| Allowed principals | Provider | Only listed accounts, users, or roles can create an endpoint to the service. |
| Acceptance required | Provider | Each connection request waits for the provider to accept it. |
| Endpoint security groups | Consumer | Limit which clients inside the consumer VPC can reach the endpoint. |
| Endpoint policy | Consumer | Restricts API actions, for endpoints to AWS services. Custom endpoint services do not use it. |
Exercise
A consumer enabled private DNS on an interface endpoint, but api.example.com still resolves to a public address from inside the VPC. Name two things to check.
Show answer
First, check that the provider's private DNS name shows as verified, which means the TXT record is in place. Second, check that the consumer VPC has both enableDnsSupport and enableDnsHostnames turned on. Also confirm that private DNS is enabled on the endpoint itself.