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

Cannot specify region_name on presigned URL #2872

Closed
richard-jones opened this issue Feb 17, 2023 · 2 comments
Closed

Cannot specify region_name on presigned URL #2872

richard-jones opened this issue Feb 17, 2023 · 2 comments
Assignees
Labels
closed-for-staleness response-requested Waiting on additional info and feedback. s3

Comments

@richard-jones
Copy link

Describe the bug

I'm attempting to set a region_name when calling generate_presigned_url. The entry method wraps a call to the request_signer and although the request_siger.generate_presigned_url allows region_name as a parameter, the entry method is not capable of passing it on, and it always defaults to the client's pre-set region. In my case, I'm attempting to access an s3 bucket, and I don't know the region of the bucket until after construction of the client, so I must construct a client, query for the bucket region, and then destroy and recreate the client.

https://github.com/boto/botocore/blob/develop/botocore/signers.py#L681

Expected Behavior

For the client to allow me to specify the region on request

Current Behavior

You cannot specify the region on request, you must recreate the client

Reproduction Steps

client = boto3.client(
            's3',
            aws_access_key_id=access_key,
            aws_secret_access_key=secret,
            config=Config(signature_version='s3v4')
        )
bucket_location = self.client.get_bucket_location(Bucket=container_id)
location = bucket_location['LocationConstraint']
return client.generate_presigned_url('get_object',
                                           Params={"Bucket": container_id, "Key": target_name},
                                           ExpiresIn=timeout,
                                           # Nowhere to specify region ...
                   )

Possible Solution

Add region_name to generate_presigned_url method signature

Additional Information/Context

No response

SDK version used

latest

Environment details (OS name and version, etc.)

Ubuntu 18.04

@richard-jones richard-jones added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Feb 17, 2023
@aBurmeseDev aBurmeseDev self-assigned this Feb 20, 2023
@aBurmeseDev aBurmeseDev added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Feb 21, 2023
@aBurmeseDev
Copy link
Contributor

Hi @richard-jones - thanks for reaching out. I came across this similar issue here and there are workaround suggested in there. One of the comments was suggested by one of our team members and let me know if that's what you're trying to accomplish.

Best,
John

@aBurmeseDev aBurmeseDev added response-requested Waiting on additional info and feedback. s3 and removed bug This issue is a confirmed bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Feb 23, 2023
@github-actions
Copy link

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness response-requested Waiting on additional info and feedback. s3
Projects
None yet
Development

No branches or pull requests

2 participants