AWS Builder Center
AWS VPC Gateway Endpoint Explained: Private Access to Amazon S3

AWS VPC Gateway Endpoint Explained: Private Access to Amazon S3

Learn how to connect an EC2 instance in a private subnet to Amazon S3 using an AWS Gateway Endpoint, without sending S3 traffic over the public internet.

431001

Introduction

AWS VPC Gateway Endpoint provides a way to access Amazon S3 privately from resources inside a VPC. It allows EC2 instances in private subnets to communicate with S3 without using a NAT Gateway or Internet Gateway for S3 traffic.

Architecture Overview

The architecture consists of:
  • VPC: Main network ( 10.0.0.0/16 ).
  • Private Subnet: Contains the EC2 instance ( 10.0.2.0/24 ).
  • EC2 Instance: Used to access Amazon S3.
  • Security Group: Controls instance-level traffic.
  • NACL: Controls subnet-level traffic.
  • Route Table: Directs network traffic.
  • Gateway Endpoint: Connects the VPC privately to Amazon S3.
  • S3 Bucket: Stores files and objects.

Practical Implementation

  1. Create a VPC and a private subnet.
  1. Launch an EC2 instance in the private subnet.
  1. Create an S3 bucket.
  1. Navigate to VPC → Endpoints → Create Endpoint.
  1. Select AWS Services → Amazon S3 Gateway Endpoint.
  1. Select your VPC and associate the private subnet's route table.
  1. Configure IAM permissions and test connectivity using AWS CLI.

How It Works

When an EC2 instance requests an object from S3:
  1. The request is sent from the EC2 instance.
  1. The route table matches the S3 prefix list.
  1. Traffic is forwarded through the Gateway Endpoint.
  1. The request reaches Amazon S3 without going through the public internet.
Note: A Gateway Endpoint does not require a NAT Gateway or Internet Gateway for S3 connectivity. Other internet traffic may still require separate routing.

Conclusion

Gateway Endpoints are useful when we want private access to Amazon S3 from resources inside a VPC. They also help reduce NAT Gateway processing costs for supported AWS traffic.


Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article