iTranslated by AI
Understanding AWS and Azure PrivateLink through Traffic Flows
Motivation
I have been continuing infrastructure-related development on AWS and on-premises, but I have been handling Azure since April.
I wanted to deepen my understanding, starting with the networking area that I frequently work with. I felt subtle differences between the providers, which motivated me to organize my thoughts.
Target Audience
- Those who want to understand the differences between AWS and Azure Private Link.
- Those who want to understand the traffic flow in each service.
Conclusion First
Focusing on the endpoints for using PrivateLink, I understood the difference that AWS provides endpoints for PrivateLink for services, whereas Azure provides endpoints for PrivateLink for resources.
It might be a matter of familiarity, but I felt that AWS, which creates endpoints on a per-service basis, is easier to understand and has better usability.
In the following sections, I will explain the traffic flow and the differences I noticed while actually creating resources.
AWS PrivateLink
AWS PrivateLink can provide private access to workloads built on AWS in addition to managed services, but this time we will focus on PrivateLink for managed services.
Traffic without VPC Endpoints
In this configuration, we will try hitting an AWS service endpoint[1] using the AWS CLI from an EC2 instance.

Traffic Flow
Let's issue an s3 ls command from the EC2 instance to check the traffic flow.
By adding the --debug option, we can see where the request is being sent, and it turns out it's being sent to "zenn-privatelink.s3.us-east-1.amazonaws.com".
[ec2-user@ip-10-0-0-176 ~]$aws s3 ls s3://zenn-privatelink --debug
(omitted)
2024-03-30 14:03:49,366 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://zenn-privatelink.s3.us-east-1.amazonaws.com
(omitted)
Next, let's check how the FQDN mentioned earlier was resolved.
A VPC has a DNS server (forwarder + full service resolver) built-in by default called Route53 Resolver.
Checking the Route53 Resolver query logs, we can see that a Public IP is resolved.
Therefore, this traffic is accessing the service endpoint via the internet.
Query Logs
{
"@timestamp": "2024-03-30 14:03:49.000",
"@message": {
"version": "1.100000",
"account_id": "365298517117",
"region": "us-east-1",
"vpc_id": "vpc-09efc2534d3f29483",
"query_timestamp": "2024-03-30T14:03:49Z",
"query_name": "zenn-privatelink.s3.us-east-1.amazonaws.com.",
"query_type": "A",
"query_class": "IN",
"rcode": "NOERROR",
"answers": [
{
"Rdata": "s3-r-w.us-east-1.amazonaws.com.",
"Type": "CNAME",
"Class": "IN"
},
{
"Rdata": "54.231.132.226",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "16.182.66.90",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.217.202.218",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.217.72.240",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "16.182.98.42",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.216.39.26",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "54.231.200.178",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.217.12.120",
"Type": "A",
"Class": "IN"
}
],
"srcaddr": "10.0.0.176",
"srcport": "46472",
"transport": "UDP",
"srcids": {
"instance": "i-08c0b194dec370347"
}
}
The traffic flow verified so far is organized as follows:

Traffic with VPC Endpoints (Interface)
Next, the configuration using PrivateLink, which is the main subject of this article. In AWS, PrivateLink is accessed via VPC endpoints. VPC endpoints are broadly categorized into two types: Interface and Gateway.
This time, we will use the Interface type. The configuration is as follows. We will perform the same operations after creating an Interface VPC endpoint in the private subnet.

Traffic Flow
First, let's issue the s3 ls command from the EC2 instance as before to check the traffic flow.
[ec2-user@ip-10-0-0-176 ~]$aws s3 ls s3://zenn-privatelink --debug
(omitted)
2024-03-30 14:15:42,349 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://zenn-privatelink.s3.us-east-1.amazonaws.com
(omitted)
Next, let's check how the FQDN mentioned earlier was resolved.
This time, a Private IP was returned.
This matches the IP address of the VPC endpoint.
Query Logs
{
"@timestamp": "2024-03-30 14:17:26.000",
"@message": {
"version": "1.100000",
"account_id": "365298517117",
"region": "us-east-1",
"vpc_id": "vpc-09efc2534d3f29483",
"query_timestamp": "2024-03-30T14:17:26Z",
"query_name": "zenn-privatelink.s3.us-east-1.amazonaws.com.",
"query_type": "A",
"query_class": "IN",
"rcode": "NOERROR",
"answers": [
{
"Rdata": "10.0.1.125",
"Type": "A",
"Class": "IN"
}
],
"srcaddr": "10.0.0.176",
"srcport": "60954",
"transport": "UDP",
"srcids": {
"instance": "i-08c0b194dec370347"
}
},
"query_name": "zenn-privatelink.s3.us-east-1.amazonaws.com."
}
The reason why the resolved IP changed despite using the same FQDN is that the VPC endpoint creation option, Enable Private DNS names, was enabled.

By enabling this option, a Private Hosted Zone is internally deployed and associated with the VPC where the VPC endpoint is deployed. This allows the Route53 Resolver to return the private IP by forwarding to the created Private Hosted Zone instead of an external DNS server.
If this option were not enabled, you would need to reference the interface endpoint using the AWS CLI's --endpoint-url option.
The traffic flow verified so far is organized as follows:

Advantages of Interface-type Endpoints
In addition to the benefits of passing through a secure and highly available network, here are some advantages compared to other methods:
- Can be specified in the Condition clause of resource-based policies
-> For S3, you can restrict traffic to those coming from the VPCE in the bucket policy's Condition clause. - Can restrict accessible resources using endpoint policies
- Can be accessed from outside the VPC (other VPCs, on-premises, etc.)
- Can control access by attaching SGs to the endpoint itself
-> As the flip side of advantage #3, I believe SGs can be applied because the VPCE itself needs to be protected.
Traffic with VPC Endpoints (Gateway)
The configuration this time is as follows. We will create a Gateway VPC endpoint in the VPC and perform the same operations.

Traffic Flow
First, let's issue the s3 ls command from the EC2 instance as before to check the traffic flow. We can confirm that it is accessing the same FQDN.
sh-5.2$ aws s3 ls s3://zenn-privatelink --debug
(omitted)
2024-03-31 11:33:38,293 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://zenn-privatelink.s3.us-east-1.amazonaws.com
(omitted)
Next, let's check how the FQDN mentioned earlier was resolved. While the Interface type earlier returned a Private IP, this time, a Public IP was returned, similar to the initial configuration without VPC endpoints.
Query Logs
{
"version": "1.100000",
"account_id": "365298517117",
"region": "us-east-1",
"vpc_id": "vpc-01f6d66a0d5780fbc",
"query_timestamp": "2024-03-31T11:36:55Z",
"query_name": "zenn-privatelink.s3.us-east-1.amazonaws.com.",
"query_type": "A",
"query_class": "IN",
"rcode": "NOERROR",
"answers": [
{
"Rdata": "s3-r-w.us-east-1.amazonaws.com.",
"Type": "CNAME",
"Class": "IN"
},
{
"Rdata": "54.231.231.34",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.217.195.58",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "54.231.133.146",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.216.209.114",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.217.198.2",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "54.231.133.210",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "16.182.103.18",
"Type": "A",
"Class": "IN"
},
{
"Rdata": "52.216.221.186",
"Type": "A",
"Class": "IN"
}
],
"srcaddr": "10.0.0.183",
"srcport": "43012",
"transport": "UDP",
"srcids": {
"instance": "i-0c9198d51db287554"
}
}
You might be a bit surprised since the flow is different, but the redirection to the Gateway VPC endpoint is handled by the route table, not DNS. Let me explain the flow of redirection via the route table.
First, when creating a Gateway endpoint, you select the route table as shown below.

A record targeting a prefix list, like the one shown below, is inserted into the specified route table.

Checking the contents of the prefix list, we can confirm that it covers the range containing the IP address resolved earlier.

This route directs the traffic to the VPC endpoint.
The traffic flow verified so far is organized as follows:

Advantages of Gateway-type Endpoints
- Can be specified in the Condition clause of resource-based policies
-> For S3, you can restrict traffic to those coming from the VPCE in the bucket policy's Condition clause. - Can restrict accessible resources using endpoint policies
- Free of charge
Azure Private Link
Azure also has a Private Link service for achieving private communication.
Traffic without Private Endpoints
In this configuration, we will try hitting an Azure REST API endpoint[2] using the Azure CLI from an Azure VM instance.

Traffic Flow
Let's issue the az storage blob list command from the Azure VM instance to check the traffic flow.
The target account name and access key have already been stored in environment variables.
By adding the --debug option, we can see where the request is being sent, and it turns out it's being sent to "zennprivatelink.blob.core.windows.net".
azureuser@zenn-test-privatelink:~$ az storage blob list -c test --debug
(omitted)
urllib3.connectionpool : https://zennprivatelink.blob.core.windows.net:443 "GET /test?restype=container&comp=list&maxresults=5000
(omitted)
Next, let's check how the FQDN mentioned earlier was resolved.
I checked it simply using the dig command.
We can see that a Public IP is resolved.
dig
azureuser@zenn-test-privatelink:~$ dig zennprivatelink.blob.core.windows.net
; <<>> DiG 9.16.48-Ubuntu <<>> zennprivatelink.blob.core.windows.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20895
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;zennprivatelink.blob.core.windows.net. IN A
;; ANSWER SECTION:
zennprivatelink.blob.core.windows.net. 60 IN CNAME blob.blz22prdstr28a.store.core.windows.net.
blob.blz22prdstr28a.store.core.windows.net. 263 IN A 20.60.0.100
;; Query time: 4 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sun Mar 31 08:48:30 UTC 2024
;; MSG SIZE rcvd: 122
Without a private endpoint, the Azure REST API is accessed via the internet.

Traffic with Private Endpoints
The configuration this time is as follows.
We will perform the same operations after creating a private endpoint in the Private Subnet.

Traffic Flow
First, let's issue the s3 ls command from the Azure VM instance as before to check the traffic flow.
[ec2-user@ip-10-0-0-176 ~]$aws s3 ls s3://zenn-privatelink --debug
(omitted)
2024-03-30 14:15:42,349 - MainThread - botocore.regions - DEBUG - Endpoint provider result: https://zenn-privatelink.s3.us-east-1.amazonaws.com
(omitted)
Next, let's check how the FQDN was resolved.
This time, a Private IP was returned.
This matches the IP address of the private endpoint.
Query Logs
azureuser@zenn-test-privatelink:~$ dig zennprivatelink.blob.core.windows.net
; <<>> DiG 9.16.48-Ubuntu <<>> zennprivatelink.blob.core.windows.net
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8534
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;zennprivatelink.blob.core.windows.net. IN A
;; ANSWER SECTION:
zennprivatelink.blob.core.windows.net. 35 IN CNAME zennprivatelink.privatelink.blob.core.windows.net.
zennprivatelink.privatelink.blob.core.windows.net. 10 IN A 10.0.4.4
;; Query time: 8 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sun Mar 31 09:09:59 UTC 2024
;; MSG SIZE rcvd: 124
Azure also creates a private DNS zone when creating an endpoint, just like AWS.

With this setting, a record is inserted, and the resolved IP address becomes the IP address of the private endpoint.

Differences between AWS and Azure noticed through hands-on experience
While there seems to be no difference between AWS VPC endpoints (Interface type) and Azure Private Endpoints, there was a major difference in the DNS records.
While Azure inserts records in FQDN format,
AWS specifies a wildcard (*) for the hostname against the service domain.

Azure

AWS
Also, when creating a Private Endpoint in Azure, you specify not only the service but even the resource name.

I still have limited experience with Azure, and Private Endpoints for other services might have different specifications, but I would like to keep these differences in mind as I proceed with estimations and designs.
Discussion