I installed the AWS command line interface on my Windows 7 box, and it worked immediately when I called commands from a DOS shell.
But DOS, the worst language ever invented, is hideous for any serious scripting. So, I would like to to use the AWS CLI from bash via cygwin.
In my case, the installed AWS CLI is the Windows version. In principle, that should not be a problem because Windows commands are executable from cygwin. (cygwin includes your Windows environmental variables, such as PATH, in its own environment.)
Unfortunately, when I first tried to execute an AWS CLI command from cygwin/bash, I got an error:
$ aws s3 cp code.tgz s3://xyz/
upload failed: .code.tgz to s3://xyz/code.tgz
Unable to locate credentials
This error is likely because the AWS CLI is looking in the wrong directory for the credentials
file. On Windows, it expects that file to be in %UserProfile%.aws
and in unix in ~/.aws
.
One hack work around is that in my home directory I created a new file named config_credentials
which contains a union of the contents of that directory's files config
and credentials
. I then made a new Windows System env var named AWS_CONFIG_FILE
whose value is the path to config_credentials
. Success: AWS CLI commands issued from cygwin now work.
I am wondering if there is a better solution?
I am curious why AWS CLI initially failed to search in the correct home directory for the config
and credentials
files. I also wonder if there is a way to correct that (this would eliminate the need for the AWS_CONFIG_FILE
env var).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…