17

I've recently started using the aws-sdk-go package.
Walking through the instructions, my folder structure is as follows:

  • bin/ , pkg/ (as always)
  • src/
    • app/main.go (code taken from the docs)
    • github.com/aws

Now when I run go install, and then execute the app.exe (using windows here),
I'm getting the following error:

panic: NoCredentialProviders: no valid providers in chain

Any ideas?

Opal
  • 81,889
  • 28
  • 189
  • 210
Asaf
  • 8,106
  • 19
  • 66
  • 116

3 Answers3

15

You need to provide an AWS access key and secret key to authenticate and use AWS services.

See the README here https://github.com/aws/aws-sdk-go#configuring-credentials

djhworld
  • 6,726
  • 4
  • 30
  • 44
  • not only that, but in some cases you need to attach a role to the instance (mine had none) https://stackoverflow.com/a/45261421/647380 – pocesar Jul 23 '17 at 04:19
  • in general you should refrain from placing access/secret keys on ec2 hosts. use roles instead. – FuzzyAmi Jan 16 '19 at 11:13
2

If anyone runs into the same issue I had with this:

I read a doc that said to put the file at %USERPROFILE%.awscredentials on a Windows, but they just forgot the slash. It should be %USERPROFILE%.aws/credentials.

1

Double check the format of your ~/.aws/credential file.

In my case, the credentials used the following format :

[profile]
AWS_ACCESS_KEY_ID=xxxx
AWS_SECRET_ACCESS_KEY=yyyy

changing it to the following fixed the issue :

[profile]
aws_access_key_id = xxxx
aws_secret_access_key = yyyy
Orabîg
  • 11,718
  • 6
  • 38
  • 58
  • This helped us there was an interesting thing where the caps version worked for python based aws cli, but failed for go based sops cli. (theory is that maybe python AWS SDK is case insensitive, but go AWS SDK is case sensitive for the config file) – neoakris May 11 '21 at 19:17