我想将用heroku制作的ghost blog连接到AWS的s3存储桶中,以便能够上传帖子中的图像。
我有我的用户ARN:arn:aws:iam :: 916616152568:user / myuser 已附加到具有“ AmazonS3FullAccess”的组。
我在做什么错了?
此存储桶的公共访问设置:
Manage public access control lists (ACLs)
Block new public ACLs and uploading public objects (Recommended)
True
Remove public access granted through public ACLs (Recommended)
True
Manage public bucket policies
Block new public bucket policies (Recommended)
False
Block public and cross-account access if bucket has public policies
(Recommended)
False
我的存储桶策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListObjectsInBucket",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::916616152568:user/*myuser*"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::*myS3bucket*"
},
{
"Sid": "AllObjectActions",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::916616152568:user/*myuser*"
},
"Action": "s3:*Object",
"Resource": "arn:aws:s3:::*myS3bucket*/*"
}
]
}
我已经将S3_ACCESS_BUCKET_NAME
,S3_ACCESS_BUCKET_REGION
,S3_ACCESS_KEY_ID
和S3_ACCESS_SECRET_KEY
上传到我的heroku环境变量中
从我的幽灵服务器上载文件时出现此错误。 Failed to load resource: the server responded with a status of 403 (Forbidden)
但是,如果我从aws控制台登录并上传,则没问题。
答案 0 :(得分:0)
您需要创建一个IAM策略,以允许您的IAM用户访问存储桶。从IAM创建类似于this的策略。然后转到您的用户,并向他附加相同的策略。
答案 1 :(得分:0)
我实际上通过将所有“存储桶的公共访问设置”更改为false来修复它。