我想使用CLI工具来检索具有特定cname /别名的CloudFront分配的分发ID.
这就是我想出的:
aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items!='null']|DistributionList.Items[?contains(Aliases.Items,'cname.cdn.mycompany.com') == 'true'].{Id:Id}"
Run Code Online (Sandbox Code Playgroud)
我不是JMESPath的专家,我不明白为什么我的查询不会返回结果.存在具有指定域作为别名的分发.
我怀疑这是我无法正确设置路径变量,但我不知所措.
我在cygwin中使用pip安装了aws cli.
pip install awscli
Run Code Online (Sandbox Code Playgroud)
我有两个python环境......一个windows anaconda发行版,cygwin可以为你安装.
which python
> /usr/bin/python
where python
> C:\cygwin64\bin\python
> C:\windows-style-path-to-anaconda\python.exe
Run Code Online (Sandbox Code Playgroud)
当我尝试运行aws cli时
aws --version
> C:\windows-style-path-to-anaconda\python.exe: can't open file
> 'cygdrive/c/cygdrive-style-path-to-anaconda/Scripts/aws':
> [Errno 2] No such file or directory'
Run Code Online (Sandbox Code Playgroud)
我已经尝试将aws的路径添加到我的windows路径变量中.没运气.
我已经尝试将其添加到我的.bashrc中
export PATH="$PATH:/cygdrive/c/cygdrive-style-path-to-anaconda/Scripts"
Run Code Online (Sandbox Code Playgroud)
没运气.
我试过修改python试图运行的'aws'.首先我修改了#!指向cygwin python而不是windows python.
#!c:\cygwin64\bin\python
Run Code Online (Sandbox Code Playgroud)
那么它可以找到文件'aws'来运行...但它找不到要导入的任何文件......'awscli.clidriver','botocore._'等.
我尝试修改我的路径变量以指向这些的位置... anaconda/Lib/site-packages ...我甚至尝试在'aws'文件本身中执行sys.path.insert(1,path). ..它解决了这个问题,但它加载的每一个文件都在其他地方查找而没有找到它们,并且在aws .py文件中一次搞乱一个太多的东西.
这是什么样的作品......在cygwin ......
cd /cygdrive/c/cygwin-path-to-anaconda/Scripts
./aws --version
> aws-cli/1.10.26 Python/2.7.11 Windows/7 botocore/1.4.17
Run Code Online (Sandbox Code Playgroud)
但必须有更好的方法,对吗?要么...
让我的路径变量设置正确
获取安装在cygwin python目录中的aws cli而不是windows anaconda环境
不幸的是,pip卸载只是挂起试图删除awscli,我不知道如果我甚至可以卸载/重新安装,如何强制它使用cygwin python.在尝试修复我的路径变量之后,我感到很茫然.
任何建议表示赞赏
我开始使用ElasticBeanstalk AWS CLI,我已经改变了一些工作流程.以前我从我的git存储库上面的目录(它是一个私有GitLab目录的克隆)部署,并转移了一些东西.
之前它的结构如下:
-- some_dir
|-- .ebextensions
| |- some_files
|
|-- my_git_directory
|- .git
|- some_files
Run Code Online (Sandbox Code Playgroud)
当我跑eb deploy:
[some_dir] $ eb deploy
... Everything is awesome.
Run Code Online (Sandbox Code Playgroud)
但是现在,我已经开始尝试从git目录进行部署,但事情并没有奏效:
-- some_dir
|-- my_git_directory
|-- .ebextensions
| |- some_files
|- .git
|- some_files
[some_dir/my_git_directory] $ eb deploy
... Everything sucks.
ERROR: An error occurred while handling git command.
Error code: 128 Error: fatal: Not a git repository (or any of the parent directories): .git
Run Code Online (Sandbox Code Playgroud)
是否有现有的测试套件可供我用来测试其实现IOBase?如果可能的话,我想详尽地测试一个新的实现,但是有很多测试需要手动编写。
例如,假设我有一个不可查找、不可写的流。我想验证我的实现read是否合规,并且所有其他方法都会引发正确类型的错误。这样的类可能如下所示:
import io
class NonSeekableReader(io.RawIOBase):
def __init__(self, b=b''):
super(NonSeekableReader, self).__init__()
self._data = io.BytesIO(b)
def seekable(self):
return False
def writable(self):
return False
def readable(self):
return True
def read(self, n=-1):
return self._data.read(n)
Run Code Online (Sandbox Code Playgroud)
也许 read 的工作正如我最初预期的那样,但也许在更复杂的实现中我会错过一些边缘情况。实验表明,这些文档至少对于预期的行为是令人困惑的。
根据python 文档,我可以看到通过定义writeablereturn False,write应该引发 an OSError(在 Python 3.5 中)。这实际上是不正确的,NotImplementedError当继承RawIOBase或AttributeError继承时它会引发IOBase。此行为不会在 中重复seekable,即调用.tell()会引发正确的错误。为了解决这个问题,我定义write如下:
def write(self, b):
raise io.UnsupportedOperation("write")
Run Code Online (Sandbox Code Playgroud)
值得注意的是,打开的文件'r'会产生预期的错误类别。
由于除了链接的文档页面之外,没有关于实现这些接口(我发现的)的一般指导,因此我什至不一定会考虑检查该问题。预先存在的测试套件可以解决这个问题。否则,对必要测试或边缘情况的描述将指导我解决这些问题。
我还没有找到这样的指导吗?
我正在尝试使用排除选项将数据从 ec2 同步到 s3 存储桶
root@ir:ls /data/
f1 f2 f3
root@ir:aws s3 sync /data/ s3://data/ --profile s3to --exclude "/data/f1/*"
root@ir:aws s3 sync /data/ s3://data/ --profile s3to --exclude "/data/f1/"
root@ir:aws s3 sync /data/ s3://data/ --profile s3to --exclude "/data/f1*"
root@ir:aws s3 sync /data/ s3://data/ --profile s3to --exclude "f1/*"
root@ir:aws --version
aws-cli/1.9.15 Python/2.7.6 Linux/3.13.0-48-generic botocore/1.3.15
Run Code Online (Sandbox Code Playgroud)
但是以上选项都不起作用,f1 继续同步到 S3 存储桶。
我生成 md5 内容哈希值用于上传验证,但最近我注意到,对于在启用 FIPS 的计算机上运行的任何用户来说,这都会失败。FIPS 禁用 openssl md5,导致ValueError我尝试初始化 hashlib 时出现错误。通常我会使用 SHA,但我依赖于需要 content-md5 标头的外部服务。
我的问题是:有没有办法强制Python使用非openssl哈希函数?这里有一些关于添加usedforsecurity标志的讨论,但似乎没有任何进展。
我在我的持续集成脚本中使用'eb deploy'.我有2个问题:
它总是返回返回码0,即使有错误.这会破坏我的部署管道,因为无法检测到错误.
它仅在命令完成后显示输出.
有没有办法让'eb deploy'像普通脚本一样工作并返回正确的错误代码?
这是volumes.json:
{
"Volumes": [
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-system",
"Key": "Name"
}
],
"VolumeId": "vol-00112233",
},
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-swap",
"Key": "Name"
}
],
"VolumeId": "vol-00112234",
},
{
"AvailabilityZone": "us-east-1a",
"Tags": [
{
"Value": "vol-rescue-storage",
"Key": "Name"
}
],
"VolumeId": "vol-00112235",
}
]
}
Run Code Online (Sandbox Code Playgroud)
我需要获取和的值,VolumeId并将Tags.Value其用作调用另一个命令的输入.从json数组中获取单个值很容易,但我无法从中提取多个值并将其传递给另一个bash命令.
我可以使用这个得到一个值:
cat volumes.json |jq -r '.Volumes[].VolumeId' |while read v; do another_bash_command $v; done
Run Code Online (Sandbox Code Playgroud)
但我无法获得多重值因为这是错误的:
cat volumes.json |jq -r '.Volumes[].VolumeId, .Volumes[].Tags[].Value' |while read …Run Code Online (Sandbox Code Playgroud)