尝试按照官方示例列出存储桶 sess, err := session.NewSessionWithOptions(session.Options{ Profile: "my-profile", }) if err != nil { exitErrorf("Unable to create session, %v", err) } // Create S3 service client svc := s3.New(sess) result, err := svc.ListBuckets(nil) if err != nil { exitErrorf("Unable to list buckets, %v", err) }请注意,my-profile(居住在~/.aws/credentials)具有关联的区域信息[my-profile]aws_access_key_id=XXXXXXXaws_secret_access_key=XXXXXXXregion=us-east-1该程序失败如下:Unable to list buckets, MissingRegion: could not find region configurationexit status 1编辑:设法通过添加这行代码来解决这个问题os.Setenv("AWS_REGION", "us-east-1")但我想正确的方法应该是让 SDK 正确读取配置文件,不是吗?
- 1 回答
- 0 关注
- 95 浏览
添加回答
举报
0/150
提交
取消