I'm trying to lern how to use the AWS-SDK for Go. I started trying to list my buckets and I am getting the following error: ... NoCredentialProviders: no valid providers in chain. Deprecated.
Here is what have done until now:
I created a user which has "AmazonS3FullAccess".
I tried placing the .aws/credentials in the same directory as my test-app and also in my home directory.
The credentials file look like this:
[my-account-name]
aws_access_key_id = adfalksnfafv (key id of the created user)
aws_secret_access_key = adsfdsafgalmnglaf (secret access key of the user)
My code looks like this:
func init() {
s3session = s3.New(session.Must(session.NewSession(&aws.Config{
Region: aws.String("sa-east-1"),
})))
}
func listBuckets() (resp *s3.ListBucketsOutput) {
resp, err := s3session.ListBuckets(&s3.ListBucketsInput{})
if err != nil {
log.Fatal("Unable to list buckets: ", err)
}
return resp
}
func main() {
fmt.Println(listBuckets())
}