The line below returns
aws quicksight list-data-sources --aws-account-id=000000000 --region eu-west-1
I would like to query by Host name. I can get to the host key but can’t make figure out how to appply value filter.
aws quicksight list-data-sources --aws-account-id=000000000 --region eu-west-1 --query "DataSources.DataSourceParameters.values(@).Host"
If you want to filter the results by a specific value, you will need to add a comparison in the query expression. If you want to display all the result fields filtered by value ‘xxx’, it should look like ‘DataSources[?DataSourceParameters.values(@).Host==`xxx`]’. For more examples and explanation, you can go here for documentation on filtering AWS CLI output.
Hope this helps.
I am afraid that your solution doesn’t work.
The following query returns an error.
aws quicksight list-data-sources --aws-account-id=000000000000 --region eu-west-1 --query "DataSources[?DataSourceParameters.values(@).Host=='abc.xxxxxx.eu-west-1.redshift.amazonaws.com']"
In function values(), invalid type for value: None, expected one of: [‘object’], received: “null”
Apologies, I didn’t look at the JSON structure properly. Please try using --query ‘DataSources[?DataSourceParameters.RedshiftParameters.Host==`xxx`]’.
It works fine now … if I may … and how would one filter by Port? When I try to filter by Port I get ‘’
The port number is without quotes: “Port”: 5439
Sorry just realised … the reason why I tried to use
is that there are also other parameters than ‘RedshiftParameters’.
I want filter by host regardless of this value.
Please take a look at the documentation related to client side filtering. The output from the AWS CLI command is JSON and you will be able to use standard JMESPath syntax to create the expressions to meet your filtering requirements in the query flag.
I have not tested it, but if you want to filter on two values (Host & Port) where both values need to be true, the expression may be something like ‘DataSources[?DataSourceParameters.RedshiftParameters.Host==`xxx` && DataSourceParameters.RedshiftParameters.Port==`xxx`]’.
Many thanks for your replay however it seems that my question was confusing. I want to find out how I can run the query but without specifying the path ‘name’ as the name can vary. For example your last statement:
I would like to replace ‘RedshiftParameters’ with an index or something else as the name can change to ‘SnowflakeParameters’. So currently to get all values I would have to run two queries:
I would like to run just one.
Any thoughts on my question?