Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS S3 IAM基于标记授予对存储桶的访问权限_Amazon Web Services_Amazon S3_Amazon Iam - Fatal编程技术网

Amazon web services AWS S3 IAM基于标记授予对存储桶的访问权限

Amazon web services AWS S3 IAM基于标记授予对存储桶的访问权限,amazon-web-services,amazon-s3,amazon-iam,Amazon Web Services,Amazon S3,Amazon Iam,我试图授予一组用户访问所有带有特定标记的s3存储桶的权限,但不允许访问所有其他存储桶。 我拼凑的政策如下所示: { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowListAll", "Effect": "Allow", "Action": [ "s3:ListAllMyBuckets"

我试图授予一组用户访问所有带有特定标记的s3存储桶的权限,但不允许访问所有其他存储桶。 我拼凑的政策如下所示:

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowListAll",
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "AllowAllIfGroup",
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Condition: : {
                "StringEquals" : {
                        "s3.ResourceTag/allow-group": "s3-access-group"
                }
            },
            "Resource": [
                "arn:aws:s3:::*",
                "arn:aws:s3:::*/*"
            ]
        }
    ] 
}
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::my-bucket",
                "arn:aws:s3:::my-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:ResourceTag/AllowGroup": "s3-access-group"
                }
            }
        }
    ]
}
我无法让它工作,我试着模拟ListBucket和ListAllMyBucket的策略,与标记的Bucket的arn比较,ListAllMyBucket工作,ListBucket失败

如果我将此策略调整为ec2(如“如果标记匹配,则授予实例开始/停止/终止”),它就像一个符咒

这是可能的还是S3不允许以这种方式匹配存储桶


(进一步澄清:我的水桶设置了“允许组”和“AllowGroup”标签,我不确定破折号是否有问题)

我做了一些实验,也无法获得您想要的结果

首先,对S3 ResourceTag的在线引用很少,但给出了一个示例:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": "arn:aws:s3:::EXAMPLE-BUCKET-NAME/*",
            "Condition": {
                "StringEquals": {
                    "S3:ResourceTag/HIPAA": "True"
                }
            }
        }
    ]
}
请注意,它使用的是
S3:ResourceTag
,而不是
S3.ResourceTag

我尝试对bucket标记和object标记使用此逻辑,但没有成功。我怀疑
ResourceTag
指的是对象级标记,而不是bucket级标记,但无法证明这一点,因为它在这两种情况下都不起作用

我使用了这样的策略:

    {
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowListAll",
            "Effect": "Allow",
            "Action": [
                "s3:ListAllMyBuckets"
            ],
            "Resource": [
                "arn:aws:s3:::*"
            ]
        },
        {
            "Sid": "AllowAllIfGroup",
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Condition: : {
                "StringEquals" : {
                        "s3.ResourceTag/allow-group": "s3-access-group"
                }
            },
            "Resource": [
                "arn:aws:s3:::*",
                "arn:aws:s3:::*/*"
            ]
        }
    ] 
}
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "Statement1",
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::my-bucket",
                "arn:aws:s3:::my-bucket/*"
            ],
            "Condition": {
                "StringEquals": {
                    "s3:ResourceTag/AllowGroup": "s3-access-group"
                }
            }
        }
    ]
}

但是,即使bucket和对象都有相应的标记,它也不会让我访问对象。

S3不支持基于bucket标记(ResourceTag)的条件键,而只支持对象标记

请参阅此处支持的条件键的完整列表(向下滚动至“Amazon S3的条件键”):


这就是它不起作用的原因。

AWS文档中提供了所有支持与AWS IAM和资源标记一起使用的服务的参考

目前,仅支持S3中的对象级标记:

¹ Amazon S3 supports tag-based authorization for only object resources.

² Amazon S3 supports service-linked roles for Amazon S3 Storage Lens.


更深入地研究文档,似乎在撰写本文时不支持对对象执行PUT和DELETE操作:

Define“我无法让它工作”。问题是什么?它根本不应该工作,这里缺少冒号:
“s3.ResourceTag/allow group”“s3访问组”
我刚检查过,缺少的冒号是c&p错误,策略说:
“s3.ResourceTag/AllowGroup”:“s3访问组”
。至于“无法让它工作”的定义:我尝试根据桶的arn模拟ListBucket和ListAllMyBucket的策略,ListBucket失败,ListAllMyBucket工作。我还对我为其生成策略的用户进行了测试,但这也不起作用。到目前为止,您找到在S3上使用ABAC的方法了吗?到目前为止,您找到在S3上使用ABAC的方法了吗?