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

bucket_exists only works if the user is the owner #70

Open
N4nn4N0 opened this issue Feb 5, 2024 · 0 comments
Open

bucket_exists only works if the user is the owner #70

N4nn4N0 opened this issue Feb 5, 2024 · 0 comments

Comments

@N4nn4N0
Copy link

N4nn4N0 commented Feb 5, 2024

It’s nice that the API offers a simple method for checking if a bucket exists. However, the implementation of client.bucket_exists() isn’t great. I have an IAM user that has access to AWS S3 and I can list buckets just fine but when calling client.bucket_exists() I get access denied. The reason for this is that under the hood client.bucket_exists() calls self.get_region().

match self.get_region(args.bucket, args.region).await {

According to the AWS documentation, you have to provide the ID for the bucket owner in order to be allowed to perform this operation. If the provided ID doesn’t match the bucket owner, you get access denied.
https://stackoverflow.com/questions/55195343/aws-s3-access-denied-when-getting-bucket-location
https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetBucketLocation.html#API_GetBucketLocation_RequestSyntax
This makes getting the region an impractical way of checking if a bucket exists.

Another reason why calling self.get_region() isn’t a great way of checking if a bucket exists is that the client caches this information locally (which makes sense for other use cases). This means that if the bucket gets deleted while the client object is still alive, client.bucket_exists() will still return true. Of course this will be very rare in practice, you don’t delete buckets that often, but it’s still not the best design.

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

1 participant