为何不检查答案感到困惑?
让我们从以上解决方案中分解每个策略声明:
此策略声明from适用于存储桶的内容,而不适用于buck本身。这可能不是问题所要的,因为您看不到存储桶中的内容。
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:GetObjectAcl",
"s3:PutObjectAcl",
"s3:ListBucket",
"s3:GetBucketAcl",
"s3:PutBucketAcl",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::your_bucket_here/*",
"Condition": {}
}
从派生的这两个语句策略可对(arn:aws:s3:::your_bucket_here/
)只读的存储区进行只读访问,但仍允许对存储区的内容(arn:aws:s3:::your_bucket_here/*
)执行CRUD操作。
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetBucketLocation",
"s3:ListBucketMultipartUploads"
],
"Resource": "arn:aws:s3:::your_bucket_here",
"Condition": {}
},
{
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:PutObjectAclVersion"
],
"Resource": "arn:aws:s3:::your_bucket_here/*",
"Condition": {}
}
但是,该策略包括以下语句,该语句允许用户查看端点上的所有存储桶。这可能不是问题所要的。
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "*",
"Condition": {}
}
但是,如果您使用浏览S3存储的客户端,则上述内容非常有用。如果您的客户直接访问存储区而不是存储桶,那么您需要访问根目录下的存储桶列表。