我的存储夹中有一个特定的文件夹,我只想将其仅限于某些文件类型。我目前有以下内容:
{
"Version": "2012-10-17",
"Id": "Policy1464968545158",
"Statement": [
{
"Sid": "Stmt1464968483619",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::my-bucket/my-folder/*"
]
"Condition": {
"StringNotEquals": {
"s3:prefix": ".txt",
"s3:prefix": ".doc"
}
},
}
]
}
我需要一些东西来替换s3:prefix
,以便系统正在查看末端,而不是查看文件和路径的开头。我尝试了s3:suffix
,但这不是一个有效的属性。
是否有S3属性在文件名的末尾进行通配符搜索,以便我只能为文件夹某些文件类型吗?
您应该能够使用通配符在Resource
中定义它。如果您希望文件夹仅限于.txt
和.doc
,请使用Effect: Allow
。
{
"Version": "2012-10-17",
"Id": "Policy1464968545158",
"Statement": [
{
"Sid": "Stmt1464968483619",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::my-bucket/my-folder/*.doc",
"arn:aws:s3:::my-bucket/my-folder/*.txt"
]
}
]
}
与使用拒绝效果相同的方法,您可以使用允许效果。两个示例均如下:
仅允许特定的特定和拒绝特定的特定。
{
"Version": "2012-10-17",
"Id": "Policy1464968545158",
"Statement": [
{
"Sid": "Stmt1464968483619",
"Effect": "Allow",
"Principal": {
"AWS": "IAM-USER-ARN"
},
"Action": "s3:PutObject",
"Resource": [
"arn:aws:s3:::bucket-name/*.doc",
"arn:aws:s3:::bucket-name/*.txt"
]
},
{
"Sid": "Stmt1464968483619",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:PutObject",
"NotResource": [
"arn:aws:s3:::bucket-name/*.png",
"arn:aws:s3:::bucket-name/*.gif"
]
}
]
}