Gulp AWS Access拒绝问题

问题描述 投票:1回答:1

这是我第一次设置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/[email protected]"
        },
        "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/*"
    }
  ]
}

这有什么明显的错误,或者问题可能在其他地方吗?

amazon-web-services amazon-s3 gulp
1个回答
0
投票

也许它与Bucket的“公共访问设置”有关。

尝试解开“阻止新的公共ACL和上传公共对象”和“删除通过公共ACL授予的公共访问权限”,如下所示:

© www.soinside.com 2019 - 2024. All rights reserved.