我正在使用 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)