- Newest
- Most votes
- Most comments
After reviewing your post here are the key issues I have identified:
- The EC2 instance is IPv6-only (no public IPv4)
- S3 VPC Gateway Endpoints currently only support IPv4 (this is a fundamental limitation)
- The ping test to s3.us-west-2.amazonaws.com is failing
- The route table isn't showing the expected S3 prefix list routes
Proposed Solution:
-
First, verify that your VPC endpoint is properly configured: aws ec2 describe-vpc-endpoints --filters Name=vpc-id,Values=<your-vpc-id>
-
Modify your CloudFormation template to ensure proper routing. The S3 endpoint needs:
S3VpcEndpoint: Type: AWS::EC2::VPCEndpoint Properties: VpcId: !ImportValue Fn::Sub: "CoreVpcId-${EnvironmentName}" ServiceName: !Sub "com.amazonaws.${AWS::Region}.s3" VpcEndpointType: Gateway RouteTableIds: - !ImportValue Fn::Sub: "CorePublicSubnet1RouteTableId-${EnvironmentName}"
- For the EC2 instance, confirm the network interface configuration:
RendezvousEc2Instance: Type: AWS::EC2::Instance Properties: NetworkInterfaces: - DeviceIndex: 0 SubnetId: !ImportValue Fn::Sub: "CorePublicSubnet1Id-${EnvironmentName}" Ipv6AddressCount: 1 AssociatePublicIpAddress: false
-
Modify your UserData script to use the AWS CLI endpoint-url parameter: aws s3 sync
--endpoint-url https://s3.${AWS::Region}.amazonaws.com
s3://${ArtifactS3Bucket}/registry-data /opt/registry-data -
Remove the ping test since it's not a reliable indicator of S3 connectivity. Instead, use: aws s3 ls --endpoint-url https://s3.${AWS::Region}.amazonaws.com
Important Notes:
- Even with IPv6-only external connectivity, your EC2 instance still needs a private IPv4 address for internal VPC communication and VPC endpoint functionality.
- The S3 VPC Gateway Endpoint operates over IPv4 internally, even if your instance doesn't have public IPv4 connectivity.
- Make sure your security group allows outbound traffic on port 443 to the VPC endpoint.
Additional Verification Steps:
-
Check route tables: aws ec2 describe-route-tables --route-table-ids <your-route-table-id>
-
Verify endpoint policy: aws ec2 describe-vpc-endpoints --vpc-endpoint-ids <endpoint-id> --query 'VpcEndpoints[].PolicyDocument'
If you're still experiencing issues after implementing these changes, you can further debug by:
- Checking VPC Flow Logs
- Verifying DNS resolution for the S3 endpoint
- Testing with a simple AWS CLI command like aws s3 ls with debug logging: aws s3 ls --debug --endpoint-url https://s3.${AWS::Region}.amazonaws.com
The above solution maintains your goal of avoiding NAT Gateways or public IPv4 addresses while enabling S3 access through the VPC endpoint.
hi AlexR,
I wonder first checking the basics by SSH into your EC2 and run the command for connectivity and Verify S3 Gateway Endpoints with Traceroute and VPC Flow Logs ?
Verify S3 Gateway Enpoint for IPv4:-
traceroute -T -p 443 s3.us-west-2.amazonaws.com
traceroute will reveal, EC2's S3 traffic is routed privately through the Gateway Endpoint using the private IPv4 network inside AWS or if it reveals multiple network hops or public IP addresses, this means the traffic is routed over the internet instead and not through the Gateway Endpoint.
If you have enabled VPC Flow Logs, you can monitor and query the flow logs to verify S3 traffic routing through the Gateway Endpoint.
Happy Troubleshooting,
The issue you're experiencing is related to a fundamental limitation of gateway endpoints: they only support IPv4 traffic, not IPv6. Since your EC2 instance is configured with only IPv6 connectivity (no public IPv4 and no NAT gateway), it cannot use the S3 gateway endpoint.
When you create a gateway endpoint, it adds routes to your route tables that direct IPv4 traffic destined for the service (S3 in this case) to the endpoint. However, since gateway endpoints don't support IPv6 traffic, there's no route being added for IPv6 traffic to S3, which explains why you're not seeing the expected route in your route table.
Your ping test to s3.us-west-2.amazonaws.com is failing because:
- The gateway endpoint only works with IPv4 traffic
- Your instance doesn't have public IPv4 connectivity
- The ping is attempting to use IPv6, which can't route through the gateway endpoint
To resolve this issue, you have a few options:
- Assign a public IPv4 address to your EC2 instance (AssociatePublicIpAddress: true)
- Use a NAT gateway to allow your instance to access S3 via IPv4
- Consider using an S3 interface endpoint instead of a gateway endpoint, as interface endpoints can support IPv6 traffic (though they have additional costs)
The simplest solution would be to enable a public IPv4 address on your instance if your architecture allows for it. This would allow the instance to use the gateway endpoint via IPv4 while still maintaining its IPv6 connectivity for other purposes.
Sources
Gateway endpoints for Amazon S3 - Amazon Virtual Private Cloud
Gateway endpoints - Amazon Virtual Private Cloud
This response doesn't quite make sense, considering the instance does have a Private IPv4 interface on the VPC.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 2 years ago

The route tables was the problem, I did not have them on the subnet that was associated to the instance.