AWS VPC Gateway Endpoint
AWS VPC Gateway Endpoint is a virtual device that enables private connectivity between your VPC and supported AWS services without requiring an internet gateway, NAT device, VPN connection, or AWS Direct Connect. Gateway endpoints provide a secure, cost-effective way to access AWS services while keeping traffic within the AWS network.
Key characteristics of VPC Gateway Endpoints:
- Private connectivity: Traffic between your VPC and AWS services never leaves the Amazon network, enhancing security.
- No additional cost: Gateway endpoints are free to use; you only pay for the data transfer and service usage.
- High availability: Gateway endpoints are horizontally scaled, redundant, and highly available VPC components.
- Route table-based: They use route table entries to direct traffic destined for the supported service to the gateway endpoint.
- No IP address required: Unlike interface endpoints, gateway endpoints don’t require IP addresses from your VPC’s address space.
Supported AWS services:
Currently, VPC Gateway Endpoints support only two AWS services:
- Amazon S3: Access S3 buckets privately without internet connectivity.
- Amazon DynamoDB: Connect to DynamoDB tables securely from within your VPC.
How VPC Gateway Endpoints work:
- Create a gateway endpoint: You create a gateway endpoint in your VPC for either S3 or DynamoDB.
- Associate route tables: You specify which route tables should be updated with routes to the gateway endpoint.
- Automatic route updates: AWS automatically adds a route to your specified route tables that directs traffic destined for the service to the gateway endpoint.
- Traffic routing: When resources in your VPC make requests to the supported service, the traffic is routed through the gateway endpoint and stays within the AWS network.
- Policy-based access control: You can attach endpoint policies to control which resources can access the service through the endpoint.
Benefits of using VPC Gateway Endpoints:
- Enhanced security: Keeps traffic within the AWS network, reducing exposure to internet-based threats.
- Cost savings: Eliminates the need for NAT gateways or internet gateways for accessing S3 and DynamoDB, reducing data transfer costs.
- Simplified architecture: Removes the complexity of managing NAT devices or internet gateways for service access.
- Improved performance: Direct connectivity can provide lower latency compared to routing through the internet.
- Compliance: Helps meet regulatory requirements that mandate private network connectivity.
Endpoint policies:
Gateway endpoints support endpoint policies, which are IAM resource policies that control access to the service. These policies allow you to:
- Restrict which S3 buckets or DynamoDB tables can be accessed through the endpoint
- Define which AWS principals can use the endpoint
- Specify allowed actions on the resources
Example endpoint policy for S3:
{
"Statement": [
{
"Sid": "AllowAccessToSpecificBucket",
"Effect": "Allow",
"Principal": "*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
Considerations and limitations:
- Service-specific: Only S3 and DynamoDB are supported; for other AWS services, use VPC Interface Endpoints.
- Regional: Gateway endpoints are regional resources and can only be used to access services in the same region.
- DNS resolution: Gateway endpoints don’t change how DNS names resolve; they work by modifying route tables.
- Route table limits: Each route table can have only one gateway endpoint per service.
- Endpoint policies: If no policy is specified, full access to the service is allowed (subject to IAM permissions).
Best practices:
- Apply least privilege: Use endpoint policies to restrict access to only the necessary resources and actions.
- Monitor usage: Use VPC Flow Logs and CloudWatch to monitor traffic through gateway endpoints.
- Use with private subnets: Gateway endpoints are particularly useful for resources in private subnets that don’t have direct internet access.
- Test endpoint policies: Thoroughly test endpoint policies before deployment to ensure they don’t inadvertently block legitimate traffic.
- Consider VPC endpoint for S3: When using S3 gateway endpoints, consider also setting up S3 bucket policies that require requests to come from your VPC endpoint.
Comparison with VPC Interface Endpoints:
| Feature | Gateway Endpoint | Interface Endpoint |
|---|---|---|
| Supported services | S3, DynamoDB | Most AWS services |
| Implementation | Route table entry | ENI with private IP |
| Cost | Free | Hourly charge + data processing |
| DNS | Uses public DNS names | Uses private DNS names |
| Security groups | Not applicable | Supports security groups |
Setting up a VPC Gateway Endpoint:
- Open the AWS VPC console
- Choose “Endpoints” from the navigation pane
- Click “Create endpoint”
- Select “Gateway” as the endpoint type
- Choose the service (S3 or DynamoDB)
- Select your VPC
- Select the route tables to be associated with the endpoint
- Configure the endpoint policy (optional)
- Create the endpoint
Once created, the gateway endpoint immediately starts routing traffic for the selected service through the private connection, keeping your data secure within the AWS network.
VPC Gateway Endpoints are an essential tool for building secure, cost-effective AWS architectures, particularly when working with S3 and DynamoDB from resources in private subnets.