这是我第一次设置Gulp任务进行发布,这是我第一次使用AWS进行更深入的工作,而不仅仅是使用已经由其他人设置的内容。
我调用任务时遇到的错误是AccessDenied: Access Denied
,我的代码是:
gulp.task('publish-staging', function() {
var publisher = awspublish.create({
params: {
Bucket: 'my-bucket',
key: 'mykey',
secret: 'mysecret',
region: 'myregion'
}
});
var headers = {
'Cache-Control': 'max-age=315360000, no-transform, public',
'Content-Encoding': 'gzip'
};
return gulp.src('build/**')
.pipe(awsPubRouter({
routes: {
'^index\\.html$': {
headers: Object.assign({}, headers, { 'Cache-Control': 'no-cache' })
},
'^.+$': { headers: headers }
}
}))
.pipe(awspublish.gzip())
.pipe(parallelize(publisher.publish(), 10))
.pipe(awspublish.reporter());
});
我的存储桶政策是:
{
"Version": "2012-10-17",
"Id": "Policy1529361802241",
"Statement": [
{
"Sid": "statement-id-1",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::848046242589:user/myuser@email.com"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Sid": "statement-id-2",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*"
},
{
"Sid": "statement-id-3",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:PutObjectAcl",
"Resource": "arn:aws:s3:::my-bucket/*"
}
]
}
这有什么明显的错误或问题可能在其他地方吗?
答案 0 :(得分:0)
也许它与存储桶的“公共访问设置”有关。
尝试取消选中“阻止新的公共ACL并上传公共对象”和“删除通过公共ACL授予的公共访问权限”: