如何获取AWS命令行界面在cygwin中工作 [英] How to get AWS command line interface to work in cygwin

查看:476
本文介绍了如何获取AWS命令行界面在cygwin中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7上安装了AWS命令行界面,当我从DOS shell中调用命令时,它立即工作。



但是DOS曾经发明,是任何严重的脚本的可怕。所以,我想通过cygwin使用bash的AWS CLI。



在我的例子中,安装的AWS CLI是Windows版本。原则上,这不应该是一个问题,因为Windows命令可以从cygwin执行。 ( cygwin在其自己的环境中包括您的Windows环境变量,例如PATH)。<不幸的是,当我第一次尝试从cygwin / bash执行AWS CLI命令时,出现错误:

  $ aws s3 cp code.tgz s3:// xyz / 
上传失败:.\code.tgz to s3://xyz/code.tgz
Unable找到凭据

这个错误很可能是因为AWS CLI在错误的目录中查找 credentials 文件。在Windows上,它期望该文件位于%UserProfile%.aws 中,并在〜/ .aws 中的unix中。



一个黑客的工作是在我的主目录中创建一个名为 config_credentials 的新文件,该目录的文件 config 凭据的内容。然后我做了一个新的Windows系统环境变量名为 AWS_CONFIG_FILE ,其值是 config_credentials 的路径。成功:从cygwin发出的AWS CLI命令现在可以正常工作。



我想知道是否有更好的解决方案?



我很好奇为什么AWS CLI最初无法在正确的主目录中搜索 config 凭据文件。我也想知道是否有一种方法来纠正(这将消除对 AWS_CONFIG_FILE env var)的需要。

解决方案

我有同样的问题。我通过在Cygwin中安装AWSCLI的新副本来解决它。你首先需要安装curl和pythonCygwin包,然后你可以安装AWSCLI如下:

  $ curl -O https://bootstrap.pypa.io/get-pip.py 
$ python get-pip.py
$ pip install awscli

如果您正在运行bash,并且之前已执行Windows AWS命令行,则需要清除缓存路径,如下所示:

  $ hash -d aws 

aws -version看起来类似于:

  aws-cli / 1.8.1 Python / 10与Windows命令相对比,CYGWIN_NT-10.0 / 2.2.1(0.289 / 5/3)

行输出,看起来类似于:

  aws-cli / 1.8.1 Python / 2.7.9 Windows / 8 

现在我可以在Cygwin下执行aws configure,一切都正常。 p>

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).

解决方案

I had the same problem. I got around it by installing a new copy of AWSCLI within Cygwin. You first need to install the "curl" and "python" Cygwin packages, then you can install AWSCLI as follows:

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ python get-pip.py
$ pip install awscli

If you're running bash, and you've previously executed the Windows AWS command line, you need to clear the cached path as follows:

$ hash -d aws

"aws --version" will then look similar to this:

aws-cli/1.8.1 Python/2.7.10 CYGWIN_NT-10.0/2.2.1(0.289/5/3)

as opposed to the Windows command line output, which looks similar to this:

aws-cli/1.8.1 Python/2.7.9 Windows/8

I'm now able to do "aws configure" under Cygwin, and everything works as it should.

这篇关于如何获取AWS命令行界面在cygwin中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆