Skip to content
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

Support environment variable for S3 addressing_style config #3190

Closed
1 of 2 tasks
skeggse opened this issue May 25, 2024 · 3 comments
Closed
1 of 2 tasks

Support environment variable for S3 addressing_style config #3190

skeggse opened this issue May 25, 2024 · 3 comments
Assignees
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue response-requested Waiting on additional info and feedback.

Comments

@skeggse
Copy link

skeggse commented May 25, 2024

Describe the feature

Allow configuring boto3 to use the virtual host style (MY-BUCKET.s3.amazonaws.com) for talking to a bucket by providing the AWS_S3_ADDRESSING_STYLE environment variable.

Use Case

If you want to force boto3 to include the region in the hostname used for boto3.client("s3", region_name="us-east-1"), you can set the AWS_S3_US_EAST_1_REGIONAL_ENDPOINT=regional in the environment variables.

If you want to force boto3 to use the virtual host style (MY-BUCKET.s3.amazonaws.com) for talking to a bucket, you have to configure it either in application code or in an accessible shared config file. Sometimes, these two options are prohibitively difficult to configure correctly, and configuring this behavior via an environment variable may be significantly easier.

Proposed Solution

Add AWS_S3_ADDRESSING_STYLE to configprovider.py's DEFAULT_S3_CONFIG_VARS' addressing_style entry.

Other Information

No response

Acknowledgements

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

SDK version used

botocore==1.34.90

Environment details (OS name and version, etc.)

macOS 14.4.1 (23E224)

@skeggse skeggse added feature-request This issue requests a feature. needs-triage This issue or PR still needs to be triaged. labels May 25, 2024
@tim-finnigan tim-finnigan self-assigned this Jun 4, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jun 4, 2024
@tim-finnigan
Copy link
Contributor

Thanks for the feature request, but I think we need more information here. When I run the following:

import boto3
client = boto3.client('s3')
boto3.set_stream_logger('')
client.list_objects(Bucket='us-east-1-bucket')

Then the debug logs show this endpoint, which is the virtual style and contains the region:

Endpoint provider result: https://us-east-1-bucket.s3.us-east-1.amazonaws.com

And if I run this:

import boto3
from botocore.config import Config
boto3.set_stream_logger('')
client_config = Config(s3={"addressing_style": "path"})
client = boto3.client('s3', config=client_config)
client.list_objects(Bucket='us-east-1-bucket')

Then the debug logs show this:

Endpoint provider result: https://s3.us-east-1.amazonaws.com/us-east-1-bucket

So the default behavior is consistent with S3 virtual hosting format: https://bucket-name.s3.region-code.amazonaws.com/key-name

Based on that, I think it's already doing what you're looking for, right? Unless I'm missing something involving your region/version or use case. And there is a (delayed) plan for S3 to deprecate path style requests. So I don't think an environment variable would be considered here.

@tim-finnigan tim-finnigan added response-requested Waiting on additional info and feedback. p2 This is a standard priority issue and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels Jun 4, 2024
@skeggse
Copy link
Author

skeggse commented Jun 4, 2024

Ah, shoot. I looked closer, and it looks like the behavior I observred was the result of using a bucket name that doesn't work as a hostname. I had assumed I was configuring something wrong.

As a side note, will bucket names with underscores stop working at some point? Obviously, we'd rather migrate, but... there are lots of priorities.

@skeggse skeggse closed this as completed Jun 4, 2024
Copy link

github-actions bot commented Jun 4, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request This issue requests a feature. p2 This is a standard priority issue response-requested Waiting on additional info and feedback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants