amazon-web-services - 如何在通过 GoLang API 创建 S3 Bucket 时设置权限?

标签 amazon-web-services go amazon-s3

我正在为 AWS 账单报告创建一个 S3 存储桶。我想在通过 GoLang API 创建 S3 存储桶时设置 GrantRead、GrantWrite 和 GrandReadACP 权限。我需要将哪个值传递给这些标签才能为经过身份验证的 AWS 用户设置这三个权限?

最佳答案

您可以查看 doc对于采用您提到的策略参数的 CreateBucket 方法

    // set your s3 client before and define your bucket as bucketName

    params := &s3.CreateBucketInput{
             Bucket: aws.String(bucketName),

             GrantRead:        aws.String("GrantRead"),
             GrantReadACP:     aws.String("GrantReadACP"),
             GrantWrite:       aws.String("GrantWrite"),
             // GrantFullControl and others available
     }

     result, err := s3client.CreateBucket(params)

作为the issue points out它可能无法正常工作,所以直接使用 ACL 之类的东西

    // set your s3 client before and define your bucket as bucketName

    params := &s3.CreateBucketInput{
             Bucket: aws.String(bucketName),

             ACL: aws.String("public-read | public-read-write")
     }

     result, err := s3client.CreateBucket(params)

参见 canned ACL doc可能的值

关于amazon-web-services - 如何在通过 GoLang API 创建 S3 Bucket 时设置权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36745327/

相关文章:

node.js - 通过 aws codebuild 为 nodejs lambda 创建 zip 文件的问题

amazon-web-services - 使用自定义 DNS 名称通过路由 53 A 记录指向我的 EC2 计算机?

amazon-web-services - CloudFormation 无法创建 AlexaSkill - 找不到资源

go - 我可以同时更新 Golang map 吗?

powershell - 使用 AWS Powershell 部署到 AWS elastic beanstalk

amazon-web-services - 由于 Amplify 上的身份验证 token 过期较短,AWS S3 预签名 URL 过期

javascript - AWS Lambda 和 Node : Write data while streaming - ends prematurely and data is missing

function - 在 Go 中是否可以调用带有命名参数的函数?

macos - 如何在Mac上从Golang代码获取总RAM?

postgresql - 使用 WAL-E 将数据从 Postgres 安全地传输到 Amazon S3