Simplifying S3 Access with an Interface VPC Endpoint and Route 53
Use Route 53 private hosted zones so clients can reach S3 through a VPC endpoint without --endpoint-url.
In 2022, accessing S3 through an interface VPC endpoint requires the --endpoint-url option. A Route 53 private hosted zone can map the standard regional S3 hostname to the endpoint so clients do not need to specify that option.

S3 VPC Endpoint
Create an interface VPC endpoint:
aws ec2 create-vpc-endpoint \ --vpc-id $YOUR_VPC_ID \ --vpc-endpoint-type Interface \ --service-name com.amazonaws.$YOUR_REGION.s3 \ --subnet-ids $YOUR_PRIVATE_SUBNET_IDS \ --security-group-ids $YOUR_SECURITY_GROUP_IDSVerify the creation of the endpoint and retrieve its DNS entries:
aws ec2 describe-vpc-endpoints \ --filters Name=service-name,Values=com.amazonaws.$YOUR_REGION.s3 \ --query "VpcEndpoints[*].DnsEntries"[ [ { "DnsName": "*.vpce-xxxxxxxxxxxxxxxxx-xxxxxxxx.s3.ap-northeast-1.vpce.amazonaws.com", "HostedZoneId": "xxxxxxxxxxxxxx" }, { "DnsName": "*.vpce-xxxxxxxxxxxxxxxxx-xxxxxxxx-ap-northeast-1a.s3.ap-northeast-1.vpce.amazonaws.com", "HostedZoneId": "xxxxxxxxxxxxxx" } ]]Confirm S3 access using the VPC endpoint’s URL:
The --region option must be specified.
aws s3 ls \ --region <YOUR_REGION> \ --endpoint-url http://vpce-xxxxxxxxxxxxxxxxx-xxxxxxxx.s3.ap-northeast-1.vpce.amazonaws.comRoute 53 Private Hosted Zone
A Route 53 private hosted zone removes the need to reference that URL directly:
aws route53 create-hosted-zone \ --name s3.$YOUR_REGION.amazonaws.com \ --vpc VPCRegion=$YOUR_REGION,VPCId=$YOUR_VPC_ID \ --caller-reference "$(date)"Add an A (ALIAS) record pointing to the VPC endpoint using the Route 53 console.
Click Create record.

Select A as the record type and choose Alias to VPC endpoint as the routing target.

After configuring the hosted zone, you can access S3 without specifying the --endpoint-url option:
The --region option must be specified.
aws s3 ls --region ap-northeast-1Conclusion
Pairing an S3 interface VPC endpoint with a Route 53 private hosted zone allows aws s3 ls to use the private endpoint without passing --endpoint-url.
Create the private hosted zone for s3.$YOUR_REGION.amazonaws.com and add an A (ALIAS) record that points to the interface endpoint. Within an associated VPC, the standard regional S3 hostname then resolves to the VPC endpoint. This is useful for tools and SDKs that do not provide an easy way to set a custom endpoint because no client-side code changes are required.
The private hosted zone is visible only through its associated VPCs. Clients in another VPC require a hosted-zone association, while on-premises clients require an appropriate DNS forwarding path, such as Route 53 Resolver endpoints and rules.
Related posts
Uploading to S3 Through CloudFront Signed URLs
CloudFront signed URLs let you upload to S3 through a custom domain—useful when direct S3 pre-signed URLs are not an option.
Handling s3:TestEvent in Amazon S3 Event Notifications
Amazon S3 sends an s3:TestEvent message when an event notification is configured. Consumers must handle its structure separately from ordinary event messages.
Querying S3 Logs with Athena and Kinesis Data Firehose
Deliver logs to S3 with Kinesis Data Firehose and query them in Athena, using custom prefixes to register partitions automatically.
Migrating from aws-vault to Granted
I migrated to Granted after aws-vault development ended. Here is how role switching and console access differ, and what to check when carrying over credentials and configuration.
Sign in with Slack Using Cognito User Pools and OIDC
Federating Cognito user pools with Slack over OIDC and wiring "Sign in with Slack" into a Next.js app with Amplify.
