2014-04-08 79 views
8

我在亞馬遜s3上創建了一個存儲桶,並添加了存儲桶策略,爲另一個用戶帳戶提供上傳文件的權限。我添加了以下存儲桶策略。無法下載由共享帳戶s3存儲桶上傳的文件

但是,現在我自己無法下載共享者上傳的文件。我想我沒有給他們授予權利。我應該如何繼續下載文件。他們可以授予他們上傳文件的權限嗎?

{ 
    "Version": "2008-10-17", 
    "Id": "Policyxxxxxxxxxxxx", 
    "Statement": [ 
     { 
      "Sid": "Stmtxxxxxxxxxxxxx", 
      "Effect": "Allow", 
      "Principal": { 
       "AWS": "arn:aws:iam::<account_number>:root" 
      }, 
      "Action": [ 
       "s3:AbortMultipartUpload", 
       "s3:GetObject", 
       "s3:ListMultipartUploadParts", 
       "s3:PutObject" 
      ], 
      "Resource": "arn:aws:s3:::<bucket_name>/*" 
     }, 
     { 
      "Sid": "Stmtxxxxxxxxxxx", 
      "Effect": "Allow", 
      "Principal": { 
       "AWS": "arn:aws:iam::<account_number>:root" 
      }, 
      "Action": [ 
       "s3:PutBucketLogging", 
       "s3:PutBucketNotification", 
       "s3:ListBucket" 
      ], 
      "Resource": "arn:aws:s3:::<bucket_name>" 
     } 
    ] 
} 

回答

7

所以問題是,Amazon S3的桶桶適用的政策,只能由區擁有者擁有的對象。因此,如果您是存儲桶所有者並通過存儲桶政策授予對象許可權,這意味着您還需要確保他們在對象上傳過程中授予您許可權。雖然授予跨賬戶權限上傳對象,但只能限制僅具有讀取權限的對象。

來源:http://docs.aws.amazon.com/AmazonS3/latest/dev/AccessPolicyLanguage_UseCases_s3_a.html 相關討論:https://forums.aws.amazon.com/thread.jspa?messageID=524342&%20#524342 例鬥政策:

{ 
    "Version":"2012-10-17", 
    "Statement":[ 
     { 
     "Sid":"111", 
     "Effect":"Allow", 
     "Principal":{ 
      "AWS":"1111111111" 
     }, 
     "Action":"s3:PutObject", 
     "Resource":"arn:aws:s3:::examplebucket/*" 
     }, 
     { 
     "Sid":"112", 
     "Effect":"Deny", 
     "Principal":{ 
      "AWS":"1111111111" 
     }, 
     "Action":"s3:PutObject", 
     "Resource":"arn:aws:s3:::examplebucket/*", 
     "Condition":{ 
      "StringNotEquals":{ 
       "s3:x-amz-grant-full-control":[ 
        "[email protected]" 
       ] 
      } 
     } 
     } 
    ] 
} 
0

我遇到了類似的問題

我從<sharerprofile>複製文件到一個新的亞馬遜帳戶在桶<bucketname> 和我由於訪問保護,無法從新的亞馬遜帳戶下載文件。

所以,我做了以下內容:

aws --profile <sharerprofile> s3api put-object-acl --acl authenticated-read --bucket <bucketname> --key <pathofthefileInBucket> 

我沒有找到如何爲多個文件自動做到這一點,所以我不得不重複同樣的命令爲每個文件

0

正面臨着類似的情況目標帳戶未被授予完全訪問權限,授予cloudfront讀取權限的存儲桶策略不起作用。

除了OP的"s3:x-amz-grant-full-control":[ "[email protected]" ]id=xxx,另一種方法是使用Canned ACL。通過使用bucket-owner-full-control,我們不必列出特定的電子郵件或規範ID。

{ 
    "Statement":[ 
    { 
     "Effect":"Allow", 
     "Principal":{"AWS":"111111111111"}, 
     "Action":"s3:PutObject", 
     "Resource":["arn:aws:s3:::examplebucket/*","arn:aws:s3:::examplebucket"] 
    }, 
    { 
     "Effect":"Deny", 
     "Principal":{"AWS":"111111111111"}, 
     "Action":"s3:PutObject", 
     "Resource":"arn:aws:s3:::examplebucket/*", 
     "Condition": { 
     "StringNotEquals": {"s3:x-amz-acl":"bucket-owner-full-control"} 
     } 
    } 
    ] 
} 
相關問題