AWScala icon indicating copy to clipboard operation
AWScala copied to clipboard

403 Forbidden with user without list all buckets right

Open nelgo opened this issue 9 years ago • 6 comments

Good Morning,

i have an issue working with this library while using an user without the right to list all existing bucket. If I got it right, every time I try to retrieve a Bucket, the library first tries to list all the existing buckets and then picks the one requested by the user, causing a 403 Forbidden error when using a "limited access" user.

Looking at how the AWS Java client deal with this situation by providing a direct method to retrieve an object by providing a bucket name and file path, i think it could be enough to add a similar method to get around the problem. For example, looking at getObject, i think adding a new

def getObject(bucketName: String, key: String)

could go.

Unfortunately I am not an S3 expert to evaluate all the possible implication, i just hope this to be useful.

What do you think?

Thanks for your work

nelgo avatar Jun 29 '15 07:06 nelgo

Maybe that would be useful for others.

seratch avatar Jul 13 '15 15:07 seratch

:+1:

There's also S3.bucket(name: String): Option[Bucket] which needlessly uses listBuckets - that means an additional roundtrip and requires permissions to list buckets even though access permissions to a single bucket would suffice.

krotton avatar Dec 03 '15 11:12 krotton

👍 +1

crakjie avatar Aug 11 '16 14:08 crakjie

Ran into this as well, and worked around it by just creating a Bucket instance directly:

val bucket: Bucket = Bucket("some-bucket-name")

maartenh avatar Nov 08 '16 15:11 maartenh

There's also S3.bucket(name: String): Option[Bucket] which needlessly uses listBuckets - that means an additional roundtrip and requires permissions to list buckets even though access permissions to a single bucket would suffice.

This needless operation can cause extra AWS bills, depending on the frequency. In our case 1000+ dollars. Calls to list buckets can result in cross region data transfers and requests. Checkout for ListAllMyBuckets in usage reports or ListBuckets in Cloudtrail logs.

adisesha avatar Feb 24 '20 03:02 adisesha

Wouldn't this method be made a lot more efficient by using the new doesBucketExists S3 client method? https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3Client.html#doesBucketExistV2-java.lang.String-

Bertrand31 avatar Aug 12 '20 13:08 Bertrand31