简体   繁体   中英

How to check whether s3 access key has access to a specific bucket or not in aws using boto3

I am trying to copy files from 2 different bucket which are in two different aws account using same access key. So it provide an error saying 403 forbidden.So what i want to do is, I want to check whether the access key that i am using to copy the file has permission to those bucket before i copy the file using boto3. Is there are anyway to do this?

If you are copying objects between Amazon S3 buckets that belong to different AWS accounts, then you will need to use a single set of credentials that have:

  • GetObject permission on the source bucket
  • PutObject permission on the destination bucket

Also, the CopyObject command should be sent to the destination bucket to avoid problems with object ownership.

Therefore, I would recommend:

  • Use credentials from the destination account ( dest-IAM-user )
  • Add a bucket policy to the source bucket that permits GetObject access by dest-IAM-user

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM