Skip to content

(short issue description)Support Virtual Host Style Naming for custom S3 Endpoints #6011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks
vardhanv opened this issue Apr 7, 2025 · 4 comments
Closed
2 tasks
Assignees
Labels
closed-for-staleness feature-request A feature should be added or improved. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.

Comments

@vardhanv
Copy link

vardhanv commented Apr 7, 2025

Describe the feature

Currently, in the S3 AWS SDK, there are only two ways to provide an S3 endpoint.

  1. Default (amazonaws.com)
  2. Custom endpoint

One of the problems with a (2), is that it does not support regions when the endpoint URL is generated.

For example, when the following configuration is used with Virtual Host Style naming

Endpoint: https://foo.com
Bucket: b1
Region: r1

It will generate S3 requests to b1.foo.com. Is there a way, or can a feature be supported to generate requests to b1.r1.foo.com, just as the SDK does when the endpoint is not specified.

Use Case

Be able to use regions with custom endpoints

Proposed Solution

When the following configuration is used with Virtual Host Style naming

Endpoint: https://foo.com
Bucket: b1
Region: r1

Generate requests to b1.r1.foo.com, just as the SDK does when the default endpoint is used.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Java SDK version used

sdk-java-v2

JDK version used

Unknown

Operating System and version

Unknown

@vardhanv vardhanv added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 7, 2025
@debora-ito
Copy link
Member

Adding the region to the custom endpointOverride should work, it doesn't?

    S3Client s3Client = S3Client.builder()
        .endpointOverride(URI.create("https://s3.us-west-2.amazonaws.com"))
        .region(Region.US_WEST_2)
        .build();

    ListObjectsResponse response = s3Client.listObjects(r -> r.bucket("debora-bucket"));

Request logs (see host):

- Sending Request: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=https, host=debora-bucket.s3.us-west-2.amazonaws.com, encodedPath=, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[])
- Received successful response: 200, Request ID: xxx, Extended Request ID: xxx

@debora-ito debora-ito self-assigned this Apr 7, 2025
@debora-ito debora-ito added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. and removed needs-triage This issue or PR still needs to be triaged. labels Apr 7, 2025
@vardhanv
Copy link
Author

vardhanv commented Apr 10, 2025

Hello,
Thank you for your response.

This (addition of us-west-2 to the URI) host=debora-bucket.s3.us-west-2.amazonaws.com only works when the URI is amazonaws.com. When a custom endpoint is specified only the bucket is prefixed to the URI, not the region.

The question is - How can we make it work for a different endpoint.

I.e if the URI was example.com, the generated host would be debora-bucket.example.com. I am looking to create debora-bucket.my-region.example.com

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Apr 10, 2025
@debora-ito
Copy link
Member

Are you saying that the URI is generated as example.com and it can't be modified to my-region.example.com? Because the following should work fine:

S3Client s3Client = S3Client.builder()
        .endpointOverride(URI.create("https://my-region.example.com"))
        .build();

ListObjectsResponse response = s3Client.listObjects(r -> r.bucket("debora-bucket"));
Sending Request: DefaultSdkHttpFullRequest(httpMethod=GET, protocol=https, host=debora-bucket.my-region.example.com, encodedPath=, headers=[amz-sdk-invocation-id, User-Agent], queryParameters=[])

Now, if you can't modify the URI, can you share a code snippet showing how are you creating the client, so we can have a little more context of your current use case?

Note that virtual host style is not supported when the bucket name contains dots, the SDK will automatically use path style, if this is the issue you're running into.

@debora-ito debora-ito added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days. label Apr 10, 2025
Copy link

It looks like this issue has not been active for more than five days. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please add a comment to prevent automatic closure, or if the issue is already closed please feel free to reopen it.

@github-actions github-actions bot added closing-soon This issue will close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will close in 4 days unless further comments are made. labels Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness feature-request A feature should be added or improved. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 10 days.
Projects
None yet
Development

No branches or pull requests

2 participants