I want images I uploaded to S3 bucket "fat" (Created two folders under it /men/shoes) to be accessed via url on internet - For UI JSON.
我希望我上传到S3存储桶“胖”(在它下面创建了两个文件夹/男人/鞋子)的图片可以通过互联网上的url访问-用于UI JSON。
I have added bucket policy and CORS but I am getting access denied. What else should I consider.
我添加了存储桶策略和CORS,但访问被拒绝。我还应该考虑什么。
{
"Version": "2012-10-17",
"Id": "Policy1694408177441",
"Statement": [
{
"Sid": "Stmt1694408172843",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::395811947099:root"
},
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::fat/*",
"arn:aws:s3:::fat"
]
},
{
"Sid": "S3PolicyStmt-DO-NOT-MODIFY-1694409137710",
"Effect": "Allow",
"Principal": {
"Service": "logging.s3.amazonaws.com"
},
"Action": "s3:PutObject",
"Resource": "arn:aws:s3:::fat/*"
}
]
}
CORS:
CORS:
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"https://fat.s3.us-west-1.amazonaws.com"
],
"ExposeHeaders": []
},
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"https://fat.s3.us-west-1.amazonaws.com"
],
"ExposeHeaders": []
},
{
"AllowedHeaders": [],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
更多回答
优秀答案推荐
Change the Principal
to *
in your bucket policy in order to grant everyone over the internet access to you bucket objects.
在您的存储桶策略中将主体更改为*,以便允许每个人通过互联网访问您的存储桶对象。
{
"Sid": "Stmt1694408172843",
"Effect": "Allow",
"Principal": "*", <-- Update Principal here
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::fat/*",
"arn:aws:s3:::fat"
]
},
..
..
..
Do you really need s3:ListBucket
action? If not, you can remove this action to adhere with the least privileges principal.
您真的需要S3:ListBucket操作吗?如果不是,您可以删除此操作以遵循最低权限原则。
更多回答
Please accept the answer if it has helped you.
如果答案对你有帮助,请接受它。
我是一名优秀的程序员,十分优秀!