aws log get-log-events --log-group-name问题

时间:2018-12-06 15:00:53

标签: aws-cli

我正在尝试检索包含aws日志的日志,但是aws cli命令未正确处理日志组名称:

$ aws logs get-log-events --log-group-name /aws/lambda/mySkillName -- log-stream-name '2018/11/28/[$LATEST]4e288b653df8409e977aa4093303761b'

An error occurred (InvalidParameterException) when calling the GetLogEvents operation: 1 validation error detected: Value 'C:/Program Files/Git/aws/lambda/mySkillName' at 'logGroupName' failed to satisfy constraint: Member must satisfy regular expression pattern: [\.\-_/#A-Za-z0-9]+

为什么aws-cli在C:/Program Files/Git前面加上日志组名称?

我正在Windows 10上运行它。在Git-Bash和cygwin bash中得到类似的结果。

更多信息:

带有--debug标志:

  

$ aws日志get-log-events --debug --log-group-name / aws / lambda / mySkillName --log-stream-name'2018/11/28 / [$ LATEST] 4e288b653df8409e977aa4093303761b'   2018-12-06 06:54:13,744-MainThread-awscli.clidriver-调试-CLI版本:aws-cli / 1.16.65 Python / 2.7.13 Windows / 10 botocore / 1.12.55   2018-12-06 06:54:13,746-MainThread-awscli.clidriver-DEBUG-在CLI中输入参数:['logs','get-log-events','--debug','--log-group-名称”,“ C:/ Program Files / Git / aws / lambda / mySkillName”,“-log-stream-name”,“ 2018/11/28 / [$ LATEST] 4e288b653df8409e977aa4093303761b”]

嗯,不,这些不是我输入CLI的参数。某些更改了--log-group-name参数。

它在做什么?

1 个答案:

答案 0 :(得分:0)

这是因为参数以/开头,并且是git-bash上的特殊挂载:

$ mount
C:/Program Files/Git on / type ntfs (binary,noacl,auto)
C:/Program Files/Git/usr/bin on /bin type ntfs (binary,noacl,auto)
C: on /c type ntfs (binary,noacl,posix=0,user,noumount,auto)

这是一个git-bash而不是aws-cli问题。

来自https://github.com/git-for-windows/build-extra/blob/master/ReleaseNotes.md

  

如果您指定以斜杠开头的命令行选项,则POSIX到Windows的路径转换将在转换例如从“ /usr/bin/bash.exe”到“ C:\ Program Files \ Git \ usr \ bin \ bash.exe”

解决方案是禁用该转换

MSYS_NO_PATHCONV=1 aws logs get-log-events ...