Python: Amazon S3 cannot get the bucket: says 403 Forbidden

前端 未结 4 810
迷失自我
迷失自我 2020-12-30 05:18

I have a bucket for my organization in Amazon S3 which looks like mydev.orgname

  • I have a Java application that can connect to Amazon S3 with th

4条回答
  •  囚心锁ツ
    2020-12-30 06:04

    Giving the user a "stronger role" is not the correct solution. This is simply a problem with boto library usage. Clearly, you don't need extra permissions when using Java S3 library.

    Correct way to use boto in this case is:

    b = conn.get_bucket('my-bucket', validate=False)
    k = b.get_key('my/cool/object.txt') # will send HEAD request to S3
    ...
    

    Basically, boto by default (which is a mistake on their part IMHO), assumes you want to interact with S3 bucket. Granted, sometimes you do want that, but then you should use credentials that have permissions for S3 bucket operations. But a more popular use case is to interact with S3 objects, and in this case you don't need any special bucket-level permissions, hence the use of validate=False kwarg.

提交回复
热议问题