我正在为 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/