简体   繁体   English

为什么即使我在存储桶策略中授予用户也无法访问我们的 S3 存储桶?

[英]why user can't access our S3 bucket even after I granted in the bucket policy?

Some other users in my organization need access to our S3 bucket.我组织中的其他一些用户需要访问我们的 S3 存储桶。 I went to the bucket policy, copied and pasted an existing section and put in the account IDs they gave me (what I call ABC and DEF).我转到存储桶策略,复制并粘贴现有部分,然后输入他们给我的帐户 ID(我称之为 ABC 和 DEF)。

They tried and still get denied when trying to List Object. Is there something else I need to do?他们尝试列出 Object 时仍然被拒绝。我还需要做些什么吗?

Do the wildcards like List* actually work, or do I have to say ListObject?像 List* 这样的通配符是否真的有效,还是我必须说 ListObject? Someone had done that elsewhere in the policy.有人已经在政策的其他地方这样做了。

{
    "Effect": "Allow",
    "Principal": {
        "AWS": [
            "arn:aws:iam::AWS-account-id-ABC:role/prod-role",
            "arn:aws:iam::AWS-account-id-DEF:role/dev-role"
        ]
    },
    "Action": [
        "s3:Get*",
        "s3:Put*",
        "s3:List*"
    ],
    "Resource": "arn:aws:s3:::bucket_name/*"
}

As the principals are in different AWS accounts both the IAM policy and bucket policy are in effect.由于委托人位于不同的 AWS 账户中,因此 IAM 策略和存储桶策略均有效。

Check the IAM policy attached to those roles for the S3:ListBucket permission.检查附加到这些角色的 IAM 策略以获得 S3:ListBucket 权限。 ( S3:ListBucket is the permission name that allows users to list objects in a bucket. ListObjects is the API call.) S3:ListBucket是允许用户列出存储桶中对象的权限名称。ListObjects 是 API 调用。)

According to the documentation , ListBucket requires a bucket resource (NOT an object resource that you provided).根据文档ListBucket需要存储桶资源(不是您提供的 object 资源)。 Therefore, I think you should modify the policy as follows.因此,我认为你应该修改政策如下。

{
    "Effect": "Allow",
    "Principal": {
        "AWS": [
            "arn:aws:iam::AWS-account-id-ABC:role/prod-role",
            "arn:aws:iam::AWS-account-id-DEF:role/dev-role"
        ]
    },
    "Action": [
        "s3:Get*",
        "s3:Put*"
    ],
    "Resource": "arn:aws:s3:::bucket_name/*"
},
{
    "Effect": "Allow",
    "Principal": {
        "AWS": [
            "arn:aws:iam::AWS-account-id-ABC:role/prod-role",
            "arn:aws:iam::AWS-account-id-DEF:role/dev-role"
        ]
    },
    "Action": [
        "s3:ListBucket"
    ],
    "Resource": "arn:aws:s3:::bucket_name"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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