-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Presigned url not creating a valid URL for af-south-1
#3015
Comments
I tracked it down to the function
Why is the config none when a region name is being specified? |
Hi @mangelozzi, thanks for reaching out. I was able to reproduce this issue. I found the solution was to include an
I also found an open issue (#2864) requesting a documentation update to cover this scenario. I’m going to create a ticket for the S3 docs team and will update that issue when I hear back from them. |
|
Possible workaround without hardcoding the URL structure: s3 = boto3.client('s3', region_name='af-south-1')
endpointUrl = s3.meta.endpoint_url
s3 = boto3.client('s3', endpoint_url=endpointUrl, region_name='af-south-1') I know, it is not nice, the fix in boto3 would be much better, but it works and no hardcoding is needed. |
Another workaround is to use an S3 Access Point in place of the bucket name. For example, let's assume you have a bucket named s3 = boto3.client('s3', region_name='af-south-1')
access_point_arn = 'arn:aws:s3:af-south-1:01234567890:accesspoint/bucketname-ap'
url = s3.generate_presigned_url('get_object', Params={'Bucket': access_point_arn, 'Key': 'object.txt'}) This will produce a URL in the correct regional format:
In fact, you don't have to specify the That said, I agree that a fix in boto3 would be preferable to any workarounds. Further investigation is needed to understand exactly when the current behavior does not work to ensure that any change we make does not also modify currently working inputs. |
…1674) aws_ssm - split S3 region/endpoint discovery into dedicated function Depends-On: #1670 SUMMARY fixes: #1616 Newer AWS regions don't generate valid presigned URLs unless you explicitly pass the endpoint_url for the region (see also boto/boto3#3015) ISSUE TYPE Bugfix Pull Request COMPONENT NAME aws_ssm ADDITIONAL INFORMATION Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None>
…1674) aws_ssm - split S3 region/endpoint discovery into dedicated function Depends-On: #1670 SUMMARY fixes: #1616 Newer AWS regions don't generate valid presigned URLs unless you explicitly pass the endpoint_url for the region (see also boto/boto3#3015) ISSUE TYPE Bugfix Pull Request COMPONENT NAME aws_ssm ADDITIONAL INFORMATION Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> (cherry picked from commit 8237ebb)
…1674) (#1677) [PR #1674/8237ebb7 backport][stable-5] aws_ssm - split S3 region/endpoint discovery into dedicated function This is a backport of PR #1674 as merged into main (8237ebb). Depends-On: #1670 SUMMARY fixes: #1616 Newer AWS regions don't generate valid presigned URLs unless you explicitly pass the endpoint_url for the region (see also boto/boto3#3015) ISSUE TYPE Bugfix Pull Request COMPONENT NAME aws_ssm ADDITIONAL INFORMATION Reviewed-by: Markus Bergholz <[email protected]>
This issue seems to be fixed from version 1.33.8 onwards provided addressing_style of virtual is specified, as of this commit: boto/botocore@4b72854#diff-b0ae51c8153e41a57c73da11fd5c8eb8d42086683ae6e8242e9d2f1979dbc1bbR854 Related issue: boto/botocore#3081 |
Can you share a python demo to show how to fix it? |
Just make sure you on v1.33.8 or higher, and set up your s3 client as follows: import boto3
from botocore.client import Config
client = boto3.client("s3", config=Config(signature_version="s3v4", s3={"addressing_style": "virtual"})) |
Describe the bug
Presigned url does not create a url for the region_name specified
Steps to reproduce
Its worth noting the code I am working on has its only mechanism for storing secrets, so they are retrieved as the variables
AWS_ACCESS_KEY_ID
,AWS_SECRET_ACCESS_KEY
, andAWS_STORAGE_BUCKET_NAME
.af-south-1
https://bucket-name.s3.amazonaws.com/test1.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIA32EU3DKFB3ACLEUV%2F20210928%2Faf-south-1%2Fs3%2Faws4_request&X-Amz-Date=20210928T130419Z&X-Amz-SignedHeaders=host&X-Amz-Expires=1800&X-Amz-Signature=0b684c8f423c9846cac3d437e3444972e2ead4f58ea967bc50c4942534aacf01
Which if tried gives an error:
Expected behavior
A url more like
af-south-1.amazonaws.com
Related to #2098, however I set the region name as shown above.
The text was updated successfully, but these errors were encountered: