Imagine a nightly ETL job that reads sensitive financial records from an Amazon S3 bucket, processes them using AWS Glue, and writes the results back to another bucket. In a standard configuration, the Glue job triggers an API request to S3 over the public internet. While the traffic is encrypted in transit via TLS, the data packets must traverse public network segments, which may violate strict organizational security policies that mandate keeping all traffic within the AWS global network.
This article explains how to use Gateway and Interface VPC endpoints to force traffic between your VPC resources and AWS services to remain entirely on the AWS private network. This approach simplifies network perimeter security, reduces reliance on public internet routing, and allows you to apply fine-grained security group controls to service-specific traffic. This guide covers S3 and Glue; it does not cover cross-region data replication or private connectivity to services outside of the AWS ecosystem.
The requirement
In regulated environments, the "data perimeter" is a primary concern. You must prove that data in transit never leaves the AWS network. By default, resources like AWS Glue jobs running in a VPC use the public endpoint of S3. To change this, you must configure VPC endpoints.
There are two primary types of endpoints to consider:
- Gateway Endpoints: Used exclusively for S3 and DynamoDB. They are free of charge, route traffic through the VPC's route table, and do not use private IP addresses.
- Interface Endpoints (AWS PrivateLink): Used for most other services (including AWS Glue APIs). These create an Elastic Network Interface (ENI) in your subnet with a private IP address, allowing you to reach the service via your VPC's private network.
flowchart TD subgraph VPC [VPC] Glue[AWS Glue Job] ENI[Glue Interface Endpoint] RT[Route Table] S3GW[S3 Gateway Endpoint] end subgraph AWS [AWS Network] S3[Amazon S3] GlueAPI[AWS Glue Service] end Glue -->|Glue API| ENI ENI -->|PrivateLink| GlueAPI Glue -->|S3 Data| RT RT -->|Gateway Path| S3GW S3GW -->|Private Path| S3 Configuring S3 Gateway Endpoints
A Gateway Endpoint for S3 is the most efficient way to route S3 traffic. It does not incur data processing charges and simplifies routing because you only need to modify the subnet's route table.
In Terraform, you define the endpoint and associate it with the route tables used by your Glue jobs:
resource "aws_vpc_endpoint" "s3" { vpc_id = var.vpc_id service_name = "com.amazonaws.${var.region}.s3" } resource "aws_vpc_endpoint_route_table_association" "example" { route_table_id = var.glue_subnet_route_table_id vpc_endpoint_id = aws_vpc_endpoint.s3.id } When you add this, the route table automatically adds a route where the destination is the S3 prefix list ID and the target is the Gateway Endpoint.
Configuring Glue Interface Endpoints
AWS Glue requires Interface Endpoints because it relies on API calls to orchestrate jobs, manage metadata, and interact with the Data Catalog. Unlike S3, these endpoints require security group rules to allow traffic on port 443.
You need endpoints for the Glue service itself and, if you are using the Data Catalog, the Glue Data Catalog service:
resource "aws_security_group" "glue_endpoints" { vpc_id = var.vpc_id ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = [var.vpc_cidr] } } resource "aws_vpc_endpoint" "glue" { vpc_id = var.vpc_id service_name = "com.amazonaws.${var.region}.glue" vpc_endpoint_type = "Interface" security_group_ids = [aws_security_group.glue_endpoints.id] subnet_ids = [var.subnet_id] private_dns_enabled = true } Setting private_dns_enabled to true is critical. It allows your code to continue using the standard AWS service endpoints (e.g., glue.us-east-1.amazonaws.com) without code changes; the VPC resolver will simply return the private IP of the interface endpoint instead of the public one.
Verify the controls
To verify that your traffic is actually staying within the private network, you can inspect the network flow or test reachability from an isolated instance.
Verify DNS resolution: From an instance inside the VPC, perform a DNS lookup for the Glue service:
nslookup glue.<region>.amazonaws.com
If the configuration is correct, the returned IP address should fall within your VPC's CIDR range.Verify S3 reachability: If you have an S3 bucket with a policy that denies non-VPC traffic, your Glue job should still be able to read data from it. If the endpoint were missing, the job would fail with a 403 Forbidden or a connection timeout (depending on your VPC's NAT Gateway configuration).
Check CloudTrail: Monitor
DescribeVpcEndpointsAPI calls in CloudTrail to audit configuration changes, and use VPC Flow Logs to observe traffic flowing to the private IP addresses of your interface endpoints.
What this doesn't cover
This setup ensures the network path remains private, but it does not replace identity-based security.
- IAM Policies: A VPC endpoint does not grant access. You still need an S3 Bucket Policy that permits access from the VPC. You can use the
aws:SourceVpcoraws:SourceVpcecondition keys in your bucket policy to explicitly restrict access to requests originating from your specific VPC or endpoint. - Data egress: Even if traffic stays on the AWS network, ensure your IAM roles follow the principle of least privilege. An S3 Gateway Endpoint is a gateway, not a firewall; it allows access to all buckets in the region unless you attach an endpoint policy to restrict access to specific buckets.
Conclusion
By implementing S3 Gateway Endpoints and Glue Interface Endpoints, you effectively remove the dependency on the public internet for your data platform's core operations. This pattern enforces a hard boundary for data traffic, which is a foundational requirement for most regulated workloads. The key decision is balancing the simplicity of Gateway Endpoints for S3 with the requirement for security group management when using PrivateLink for service APIs. For your next step, review your existing IAM bucket policies and add a condition block restricting access to your new aws:SourceVpce IDs to further harden your perimeter.
Tags: #aws #security #s3 #glue
Cover photo by Alex Zaj on Unsplash.
This article was drafted with AI assistance and is intended for technical review and fact-checking before publication.

