Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

aws log get-log-events --log-group-name problem

Tags:

aws-cli

I am trying to retrieve a log with aws logs, but the log group name is improperly processed by the aws cli command:

$ 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]+`

Why is aws-cli prepending C:/Program Files/Git to the log group name?

I am running this on Windows 10. I get similar results in Git-Bash and cygwin bash.

More information:

With the --debug flag:

$ aws logs 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 - DEBUG - CLI version: 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 - Arguments entered to CLI: ['logs', 'get-log-events', '--debug', '--log-group-name', 'C:/Program Files/Git/aws/lambda/mySkillName', '--log-stream-name', '2018/11/28/[$LATEST]4e288b653df8409e977aa4093303761b']

Um, no, those are not the arguments I entered to the CLI. Something has changed the --log-group-name argument.

What is it doing this?

like image 403
Ed Van Horne Avatar asked Dec 06 '18 15:12

Ed Van Horne


1 Answers

It's because the argument starts with / and it is a special mount on 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)

It is a git-bash not aws-cli issue.

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

If you specify command-line options starting with a slash, POSIX-to-Windows path conversion will kick in converting e.g. "/usr/bin/bash.exe" to "C:\Program Files\Git\usr\bin\bash.exe"

The solution is to disable that conversion

MSYS_NO_PATHCONV=1 aws logs get-log-events ...
like image 102
Крис Avatar answered Sep 22 '22 15:09

Крис