Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows git bash tries to resolve string as file when calling AWS CLI

I have a string parameter for AWS SSM CLI command that looks like a path to a file due to starting with a /. /path/to/my/param.

When I run the command on git bash it tries to find the file instead, no matter how I try to escape it:

aws ssm get-parameter --name "/path/to/my/param"

aws ssm get-parameter --name '/path/to/my/param'

aws ssm get-parameter --name '\/path\/to\/my\/param'

An error occurred (ValidationException) when calling the GetParameter operation: Invalid label format /Program Files/Git/path/to/my/param. A label name can't be prefixed with numbers, "ssm", or "aws" (case-insensitive). You can specify letters, numbers, and the following symbols: period (.), dash (-), or underscore (_).

Even tried back-ticks, then I get a bash error

aws ssm get-parameter --name `/path/to/my/param`

Error: bash: /path/to/my/param: No such file or directory

If I do echo /asd/asd it actually outputs /asd/asd, so it also might be how the aws cli is treating the input.

Any ideas how to escape it?

like image 653
LLL Avatar asked Dec 23 '22 02:12

LLL


1 Answers

It is possible to turn off a path conversion in MSYS2 for selected paths (see Msys2 Porting, Filesystem namespaces section).

You can also disable it temporarily in the following way:

 MSYS2_ARG_CONV_EXCL="/aws" aws ssm get-parameter --name '/aws/path/to/my/param'
like image 185
zllvm Avatar answered May 07 '23 00:05

zllvm