【发布时间】:2018-12-20 15:25:41
【问题描述】:
我有 2 个 AWS 账户(accountA 和 accountB)。 A 拥有名为 bucketA 的 s3 存储桶。 BucketA 配置为我们的 CloudFront 分配之一的日志存储桶。因此,bucketA 中的对象属于 awsdatafeed 帐户。此存储桶中示例对象的 ACL 为:
{
"Owner": {
"DisplayName": "awsdatafeeds",
"ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
},
"Grants": [
{
"Grantee": {
"DisplayName": "awsdatafeeds",
"ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Type": "CanonicalUser"
},
"Permission": "FULL_CONTROL"
},
{
"Grantee": {
"DisplayName": "accountA",
"ID": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"Type": "CanonicalUser"
},
"Permission": "FULL_CONTROL"
}
]
}
现在,我希望 accountB 中的 IAM 用户能够访问此 S3 存储桶中的对象。所以,我按照https://docs.aws.amazon.com/AmazonS3/latest/dev/example-walkthroughs-managing-access-example2.html中的说明进行操作
我在 bucketA 中添加了以下 Bucket Policy:
{
"Version": "2012-10-17",
"Id": "Policy1531389545571",
"Statement": [
{
"Sid": "Bucket Permissions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::accountB:root"
},
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucketA",
"arn:aws:s3:::bucketA/*"
]
}
]
}
现在,在 accountB 中,我向用户添加了以下 IAM 策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::bucketA",
"arn:aws:s3:::bucketA/*"
]
}
]
}
现在,使用 AccountB 中的 IAM 用户的凭证,我可以列出存储桶 A 中的对象并创建新对象。但是,当我尝试获取属于 bucketA(其所有者是 awsdatafeeds 帐户)中的现有对象时,我收到以下错误:
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
如何从 AccountB 访问这些日志文件?
【问题讨论】:
标签: amazon-web-services amazon-s3 acl amazon-iam