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

can we pass endpoint_url? #10

Open
iamtennislover opened this issue Aug 7, 2024 · 1 comment
Open

can we pass endpoint_url? #10

iamtennislover opened this issue Aug 7, 2024 · 1 comment

Comments

@iamtennislover
Copy link

hi there, is there a way to pass endpoint_url to override sts endpoint?

@benkehoe
Copy link
Owner

benkehoe commented Sep 6, 2024

What is your intention here? The normal function of boto3 is to use either the global STS endpoint or the regional endpoints (corresponding to whichever region is set on the session). Any recent version of boto3 will default to regional, but can be set to the global endpoint with the sts_regional_endpoints config value set to legacy, see here. On your boto3 Session you'd do session._session.set_config_variable('sts_regional_endpoints', 'legacy')

Is there a different URL you want to use, that you want to override the endpoint_url parameter used to create the STS client that is used to make the AssumeRole call? There's not a clean, simple way to do it that feels right to implement here. If you have need to do it, I'd suggest copying the library (it's just the one file) and then on line 212, you'd wrap botocore_session.create_client, something like making a function like this:

def get_client_creator(botocore_session, client_creator_kwargs):
    def create_client(*args, **kwags):
        kwargs.update(client_creator_kwargs) # client_creator_kwargs overrides kwargs, I am not sure if this is always the correct behavior
        return botocore_session.create_client(*args, **kwargs)
    return create_client

and then line 212 would be get_client_creator(botocore_session.create_client, {"endpoint_url": "my_endpoint_url"}) and you'd alter assume_role() to take your endpoint URL as an additional parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants