我有一个 S3 存储桶,其结构如下:
top_level_name
sub_level_1
sub_level_2
sub_level_3
我想对所有操作进行全面拒绝top_level_name
(以排除原本有权访问此存储桶的 IAM 策略),并有选择地允许特定用户访问他们各自的sub_levels
. 最初我认为该政策可能类似于:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyTopLevel",
"Action": [
"s3:*"
],
"Effect": "Deny",
"Resource": "arn:aws:s3:::test-bucket/top_level_name/*",
"Principal": "*"
},
{
"Sid": "AllowSubLevel1",
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::test-bucket/top_level_name/sub_level_1/*",
"Principal": {
"AWS": [
"arn:aws:iam::12345:user/my_user_account"
]
}
}
]
}
在执行过程中,Allow 似乎无法取代 Deny。有没有办法可以重写我的存储桶策略来实现这种模式?