Interview Prep/AWS/VPC and Networking

Traffic from your VPC to S3 goes through the NAT gateway. How do you keep it on the AWS network and add control?

IntermediateScenarioVPC and Networking
Answer

Situation read → A gateway endpoint routes S3 traffic privately and allows policy control at no charge.

What I'd do →

  1. Create the endpoint: aws ec2 create-vpc-endpoint --vpc-id vpc-0abc --service-name com.amazonaws.eu-west-1.s3 --route-table-ids rtb-0abc
  2. Attach an endpoint policy restricting access to your buckets
  3. Add a bucket policy condition aws:SourceVpce so the bucket is only reachable through the endpoint
  4. Verify with traceroute or route table entry for the prefix list

Why → The endpoint adds a prefix-list route that wins over the default route, so NAT is bypassed.

Interview tip → Gateway endpoints exist only for S3 and DynamoDB; everything else uses interface endpoints.

aws All AWS questions Roadmap: AWS core services

More on VPC and Networking