boto3 icon indicating copy to clipboard operation
boto3 copied to clipboard

Provide environment variables to override default endpoint URL

Open arthurzenika opened this issue 4 years ago • 9 comments

In a world of environment variables used as configuration to switch between environments, it would be really useful if boto3 would support an variable to switch between endpoints.

In our use case we want to use boto3 with minio https://min.io in the dev and continuous integration environments and switching with a variable such as AWS_S3_ENDPOINT_URL would be super useful.

Right now, we have to hack our way though some custom python code, or have some startup writing of an aws configuration file, which is not ideal.

See https://docs.min.io/docs/aws-cli-with-minio for how the "alternative" entrypoint is used.

arthurzenika avatar Aug 29 '19 15:08 arthurzenika

@arthurlogilab - Thank you for your post. I would mark this as a feature request. But for now as a workaround you can use endpoint_url during client creation.

Here is the documentation for how to use endpoint_url during client creation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

swetashre avatar Aug 29 '19 23:08 swetashre

It would be nice to have as in some cases boto3 is used as dependency and there's no way to access it's constructor - environment variables is the only way to change configuration.

oleksandr avatar Apr 22 '20 17:04 oleksandr

I've submitted a PR to provide this endpoint_url env var. If it doesn't get accepted or needs more work, you might find my boto3 fork gives you what you need in the meantime. https://github.com/rwillmer/boto3

rwillmer avatar Jan 30 '21 23:01 rwillmer

As I mentioned back in Jan, I've submitted a PR back in Jan to provide a fix for this which people would like to see in core. What's the process for getting someone to review and merge?

rwillmer avatar Apr 21 '21 07:04 rwillmer

@kdaily This is a pretty highly requested feature with simple implementation that has been ready to merge for nearly a year #2746. Is there anything else that needs to be done to get this merged?

bradenkinard avatar Dec 17 '21 17:12 bradenkinard

+1 for this feature request

serbannistor avatar Feb 15 '22 10:02 serbannistor

I'm trying to use tensorboard with a private s3 service, but the constructor of boto3.client is using the default endpoint_url...

ThyrixYang avatar Mar 25 '22 09:03 ThyrixYang

Thank you for posting your feedback here, and our apologies that we’ve been thinking this over for a long time without much forward motion. There are similar requests to implement this feature in a few of the AWS SDKs and the AWS CLI, so in order to coordinate those teams - and hopefully make the discussions a little easier to follow - we’ve created a new issue in aws/aws-sdk here: https://github.com/aws/aws-sdk/issues/229

kellertk avatar Apr 26 '22 20:04 kellertk

Hi all,

We recently added a pull request (https://github.com/aws/aws-sdk/pull/230) that contains a proposal based on community comments and suggestions and our own discussions. This document proposes to extend the options for configuring the endpoint to allow users to provide an endpoint URL independently for each AWS service via an environment variable or a profile subsection in the shared configuration file.

You can read the proposal here.

For more information on how to give feedback, please see this comment on the aws/aws-sdk repository:

https://github.com/aws/aws-sdk/issues/229#issuecomment-1118725725

Thanks!

tim-finnigan avatar May 12 '22 17:05 tim-finnigan

I'm happy to announce that the ability to configure the endpoint URL via the shared configuration file and environment variables is now available in the AWS Python SDK! You can now specify the endpoint to use for all service requests through the shared configuration file and environment variables, as well as specify the endpoint URL for individual AWS services.

To start using this feature, install boto3>=1.28.0.

To read more about this feature, see the documentation page "Service-specific Endpoints" in the AWS SDKs and Tools Reference Guide:

https://docs.aws.amazon.com/sdkref/latest/guide/feature-ss-endpoints.html

Look forward to a blog post demonstrating the use of this feature on the AWS Developer Tools Blog!

kdaily avatar Jul 07 '23 21:07 kdaily