Some Applications Timeout When Accessing S3 Through VPC Endpoint While Others Work

0

We currently have multiple VPCs across different AWS accounts within our organization. In our production VPC, we've created an interface VPC endpoint for S3 with the 'Enable Private DNS Name' option enabled. We have an application that needs to access a specific S3 bucket (company-finance-reports) using the endpoint, but we're experiencing some unexpected behavior:

  • Some of our applications can successfully access the bucket using the standard S3 endpoint URL (company-finance-reports.s3.us-east-1.amazonaws.com)
  • Other applications running in the same VPC are getting timeout errors when trying to access the same bucket
  • We've verified that all security groups and bucket policies are correctly configured
  • All applications are using the AWS SDK with default configurations

Our security team requires that all S3 access must go through the VPC endpoint, and we need to ensure consistent behavior across all our applications.

asked 18 days ago77 views
4 Answers
1
Accepted Answer

The inconsistent behavior you’re experiencing is likely due to a combination of DNS resolution caching and application configuration. When you enable the private DNS name option for S3 VPC endpoints, AWS automatically creates private hosted zone entries that override the default S3 endpoint resolution within your VPC. However, this behavior can be affected by

  1. DNS TTL (Time To Live) caching at the application or OS level
  2. Custom DNS configurations in your applications
  3. Hard-coded IP addresses or custom endpoints in application configurations

For this you can try to - Restart applications that are experiencing timeouts to clear any cached DNS entries.

  • Verify that your applications aren’t using custom DNS resolvers that bypass VPC DNS
  • Check the EC2 instances’ DNS settings with: cat /etc/resolv.conf
  • Further use Use VPC Flow Logs to monitor traffic to S3 endpoint IPs to narrow down the issue.
profile pictureAWS
answered 17 days ago
  • This helps! We actually checked our DNS policy and found out the issue.

1

If the S3 bucket is in the same region as the VPC, I would recommend creating a VPC gateway endpoint instead of a VPC interface endpoint for S3. Gateway endpoints are entirely free of charge, as opposed to interface endpoints that incur both fixed per-hour fees for each AZ in which an elastic network interface (ENI) is provisioned and per-gigabyte fees for all traffic passing through it.

Gateway endpoints act as IP routers, so they don't use security groups. However, if you need to restrict access to S3 through the gateway endpoint, they do support VPC endpoint policies. With an endpoint policy, you can control which principals (IAM roles or users) are allowed to connect to S3 through the endpoint, which buckets or accounts/organisations owning them are permitted, or you can enforce encryption settings or any other aspects for S3 access that can be controlled by IAM policies.

When you associate the appropriate VPC route tables with your gateway endpoint, all traffic to S3 in the region will be transparently routed through the gateway endpoint. Nothing needs to be separately configured regarding DNS configuration, security groups, or application settings.

EXPERT
answered 18 days ago
profile pictureAWS
EXPERT
reviewed 15 days ago
profile picture
EXPERT
reviewed 17 days ago
  • Will take a look at the Gateway endpoints too. Thank you for pointing it out.

1

The issue you're experiencing with inconsistent access to your S3 bucket through the VPC endpoint could be related to a few factors:

  1. DNS Resolution: When you enable the 'Enable Private DNS Name' option for an S3 interface endpoint, it overrides the public DNS resolution for S3 endpoints within that VPC. This means that all S3 requests should be routed through the VPC endpoint. However, if DNS settings are not properly configured in your VPC, some applications might still attempt to use the public S3 endpoint, leading to timeouts.

  2. Endpoint Type: You mentioned using an interface VPC endpoint for S3. However, for S3, it's generally recommended to use a gateway endpoint instead. Gateway endpoints are specifically designed for S3 and DynamoDB, and they're more cost-effective and easier to set up. If you're using an interface endpoint, it might cause some unexpected behavior.

  3. Region Specificity: If your applications are not explicitly specifying the region when making S3 requests, they might default to us-east-1. This could cause issues if your VPC endpoint is in a different region.

  4. SDK Configuration: While you mentioned that all applications are using the AWS SDK with default configurations, it's possible that some applications are overriding these defaults or using different versions of the SDK that handle VPC endpoints differently.

To resolve these issues and ensure consistent behavior:

  1. Verify that DNS hostnames and DNS resolution are enabled for your VPC.

  2. Consider switching to a gateway endpoint for S3 instead of an interface endpoint.

  3. Ensure all applications explicitly specify the correct region when making S3 requests.

  4. Review the SDK configurations across all applications to ensure they're consistent and properly configured to use VPC endpoints.

  5. Check that the VPC endpoint policy allows access to the specific S3 bucket (company-finance-reports) for all necessary actions.

  6. Verify that the route tables for your subnets have the correct routes to the S3 endpoint.

  7. If using custom endpoint URLs, ensure they're correctly formatted and consistently used across all applications.

By addressing these points, you should be able to achieve consistent access to your S3 bucket through the VPC endpoint across all your applications, meeting your security team's requirements.
Sources
Accessing s3 from a Lambda within a vpc | AWS re:Post
Controlling access from VPC endpoints with bucket policies - Amazon Simple Storage Service
S3 endpoint doesn't work | AWS re:Post
Gateway endpoints for Amazon S3 - Amazon Virtual Private Cloud

profile picture
answered 18 days ago
profile pictureAWS
EXPERT
reviewed 15 days ago
profile pictureAWS
EXPERT
reviewed 18 days ago
0

Since you are getting consistent failures from certain applications, something in your setting is blocking connectivity. Since you are confident with S3 bucket policy and application security groups, the only other thing to check is your endpoint. Check the following for your S3 interface

  • Security Groups: check if it has necessary inbound rules
  • Subnets: check if the subnet has NACL blocking traffic and has the correct routing policy in route table
  • Policy: confirm it's allowing application's IAM role access
answered 18 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions