【发布时间】:2020-10-23 02:29:48
【问题描述】:
我正在尝试在特定资源具有某些标签键/值对的条件下提供对 IAM 策略的访问权限。尽管关注了AWS documentation,但它似乎不起作用。
IAM 政策如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/environment": "dev"
}
}
}
]
}
我有一个 S3 存储桶(名为 my-bucket-name),其标签为:environment = dev。谁能向我解释为什么以下命令失败?
$ aws s3 ls s3://my-bucket-name
An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
$ aws s3 cp s3://my-bucket-name/file.json .
fatal error: An error occurred (403) when calling the HeadObject operation: Forbidden
更新:基于 @Dennis Traub 和 @jarmod 响应,我稍微编辑了这个以将标签添加到 S3 存储桶中的对象,我是仍然无法读取对象。我还尝试将条件更改为"s3:RequestObjectTag/environment": "dev",但仍然不行。
【问题讨论】:
标签: amazon-web-services amazon-s3 amazon-iam