How to verify that VPC traffic to S3 is going through your S3 gateway?
Gateway endpoints for Amazon S3 are a must-have whenever your EC2 instances send and receive traffic from S3, because they allow the traffic to stay within the AWS network, hence better security, bandwidth, throughput, and costs. They can easily be created, and added to your VPC route tables.
But how do you verify that traffic is indeed going through the S3 gateway, and not crossing the outer internet?
Using traceroute
, you can probe the routes and see whether you are directly hitting the S3 servers (i.e. no intermediate gateway). In this example, the instance is running from a VPC located in us-east-1
:
Both outputs produce the expected result, i.e. no intermediary gateway. This is what would happen if you were accessing a bucket located in the us-east-1
region.
Let’s see what happens if we try to access an S3 endpoint located in another zone:
As you can see, the route is completely different, and as expected does not hit straight to the S3 endpoint.
TL;DR: make sure your route tables are correct, and only point to S3 buckets located in the same region.