I am trying to run aws command using Golang's command function in os/exec
package. But it gives error on doing so.
command: aws s3 cp SOURCE_DIR s3://BUCKET_NAME/TARGET_DIR --recursive
error: Unable to locate credentials
But credentials are set as shared configuration file
. Please guide me what I am doing wrong here and how it can be resolved.
CodePudding user response:
Assuming the Go program is run with the right user, try and execute instead aws configure list
As explained in this thread, you will see how your credentials are configured:
- config file
- environment variable
- instance profile
- or... not at all, in the context of your Go runtime session.
Also the credentials file is with a different user and the directory which is being copied is with different user. can this be the issue ?
Yes, that is the point of this answer: double-check what your Go program sees during its execution, in term of environment variable (like $HOME
).