I am running an AWS query
command for aws fsx describe-file-systems
where I want to combine two operators where it will be looking for FileSystemType=="LUSTRE"
and another where Storagecapacity >1200
and then following the another stuff with the query.
In order to get the results I tried below command which came with an error:
aws fsx describe-file-systems --query "FileSystems[?FileSystemType=='LUSTRE' && Storagecapacity >1200 ] | reverse(sort_by(@, &LustreConfiguration.PerUnitStorageThroughput))[].{Name:Tags[?Key=='Name']|[0].Value, Storagecapacity:StorageCapacity, FS_ID:FileSystemId,Type:FileSystemType, Mount:LustreConfiguration.MountName, Throughput:LustreConfiguration.PerUnitStorageThroughput, Maintainancewindow:LustreConfiguration.WeeklyMaintenanceStartTime}" --profile demo --output table --no-cli-pager
Error produced by the above command:
Bad value for --query FileSystems[?FileSystemType=='LUSTRE' && Storagecapacity >1200 ] | reverse(sort_by(@, &LustreConfiguration.PerUnitStorageThroughput))[].{Name:Tags[?Key=='Name']|[0].Value, Storagecapacity:StorageCapacity, FS_ID:FileSystemId,Type:FileSystemType, Mount:LustreConfiguration.MountName, Throughput:LustreConfiguration.PerUnitStorageThroughput, Maintainancewindow:LustreConfiguration.WeeklyMaintenanceStartTime}: invalid token: Parse error at column 58, token "1200" (NUMBER), for expression:
"FileSystems[?FileSystemType=='LUSTRE' && Storagecapacity >1200 ] | reverse(sort_by(@, &LustreConfiguration.PerUnitStorageThroughput))[].{Name:Tags[?Key=='Name']|[0].Value, Storagecapacity:StorageCapacity, FS_ID:FileSystemId,Type:FileSystemType, Mount:LustreConfiguration.MountName, Throughput:LustreConfiguration.PerUnitStorageThroughput, Maintainancewindow:LustreConfiguration.WeeklyMaintenanceStartTime}"
^
My Own Observation:
If i should look at the above error it doesn't like the comparison operation with int
value which I am providing.
Any help would be much appreciated.
While working with
json
data type, It's quite obvious that AWS for Linux and macOS you need to interpret strings literally using single quotation marks' '
to enclose the JSON data structure and get the operator values interpreted. You need to use the command substitution(``).So, if you use the below command it should work for you...
Now, if you look at the above syntax, it's very explicit that the complete command body is enclosed within single quotes
''
and the Value against the operators are within the command substitution(``)
IE backticks which then correctly expands its value as desired.Result: