小编Uts*_*sab的帖子

AWS Golang S3 管理器上传:访问被拒绝

我正在使用 S3 上传管理器将大文件上传到 S3。

if _, err := uploader.UploadWithContext(ctx, &s3manager.UploadInput{
        Bucket:          aws.String(s.Config.GetS3ExportBucket()),
        Key:             aws.String(key),
        Body:            bytes.NewReader(buf.Bytes()),
        ContentEncoding: aws.String("gzip"),
        ContentType:     aws.String("application/json"),
    }); err != nil {
        return fmt.Errorf("failed to upload file, %w", err)
    }
Run Code Online (Sandbox Code Playgroud)

根据AWS 文档,我也向我的 lambda 提供了权限。

#Created Policy for IAM Role
resource "aws_iam_policy" "s3_write_policy" {
  name        = "${local.namespace}-s3-write-access"
  description = "Allow Lambda to access s3 where back will be written"
  policy      = data.aws_iam_policy_document.s3_write_policy.json
}

data "aws_iam_policy_document" "s3_write_policy" {
  statement {
    sid       = "WriteObjectActions"
    effect    = "Allow"
    actions …
Run Code Online (Sandbox Code Playgroud)

amazon-s3 go amazon-web-services aws-lambda terraform

1
推荐指数
1
解决办法
1410
查看次数