我如何才能拥有拒绝访问除以字符串 "xyz" 开头的所有存储桶以外的所有存储桶的 s3 策略?
How can i have s3 policy that denies access to all buckets except the ones that start with string "xyz"?
我想制定拒绝访问所有存储桶的策略,但以特定命名约定开头的存储桶除外,即如果它们以 "xyz" 开头。我怎样才能写一个政策来做到这一点?下面的一个有效,但它会引发各种警告:
"You choose actions that require the bucket resource type"
要么
"One or more actions may not support this resource"
要么
“您策略中的操作不支持资源级权限,需要您选择所有权限。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:ListAllMyBuckets",
"s3:CreateBucket"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:PutBucketPublicAccessBlock",
"s3:PutEncryptionConfiguration",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::xyz*",
"arn:aws:s3:::xyz*/*"
]
}
]
}
你的政策对我的测试非常有效。
我必须解决您政策中的一些格式问题(我已将其应用到您的问题中)——具体来说,就是一些弯引号和一个额外的逗号。
我输入的政策是JSON。
我想制定拒绝访问所有存储桶的策略,但以特定命名约定开头的存储桶除外,即如果它们以 "xyz" 开头。我怎样才能写一个政策来做到这一点?下面的一个有效,但它会引发各种警告:
"You choose actions that require the bucket resource type" 要么 "One or more actions may not support this resource" 要么 “您策略中的操作不支持资源级权限,需要您选择所有权限。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:ListAllMyBuckets",
"s3:CreateBucket"
],
"Resource": "arn:aws:s3:::*"
},
{
"Effect": "Allow",
"Action": [
"s3:PutBucketPublicAccessBlock",
"s3:PutEncryptionConfiguration",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::xyz*",
"arn:aws:s3:::xyz*/*"
]
}
]
}
你的政策对我的测试非常有效。
我必须解决您政策中的一些格式问题(我已将其应用到您的问题中)——具体来说,就是一些弯引号和一个额外的逗号。
我输入的政策是JSON。