CLI Quicksight filter


The line below returns

aws quicksight list-data-sources --aws-account-id=000000000  --region eu-west-1

“DataSources”: [
“Arn”: “arn:aws:quicksight:eu-west-1:00000000:datasource/0000000c-0000-4f80-b992-c00000000”,
“DataSourceId”: “0000000c-0000-4f80-b992-c00000000”,
“Name”: “DWH”,
“Type”: “REDSHIFT”,
“CreatedTime”: “2018-07-25T15:58:57.582000+02:00”,
“LastUpdatedTime”: “2018-07-25T15:58:57.665000+02:00”,
“DataSourceParameters”: {
“RedshiftParameters”: {
“Host”: “”,
“Port”: aaaa,
“Database”: “ccc”,
“ClusterId”: “vvv-dwh-ddddd”
“SslProperties”: {
“DisableSsl”: false
} …

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.


1 Like

Hi @Krishna

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=='']"


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`]’.


1 Like

Thanks Krishna!

It works fine now :slight_smile: … 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
Many thanks,

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`]’.

Hi Krishna,

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:

‘DataSources[?DataSourceParameters.RedshiftParameters.Host==xxx && DataSourceParameters.RedshiftParameters.Port==xxx]’

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:

‘DataSources[?DataSourceParameters.RedshiftParameters.Host==xxx && DataSourceParameters.RedshiftParameters.Port==xxx]’


‘DataSources[?DataSourceParameters.SnowflakeParameters.Host==xxx && DataSourceParameters.SnowflakeParameters.Port==xxx]’

I would like to run just one.

Many thanks,

Hi @Krishna,
Any thoughts on my question?

Hello @ArtSal !

I marked @Krishna original answer to your first question as a solution because it looks like you had another related question but the original issue was resolved.

Are you still running into this issue, or if you found a solution do you mind posting your answer to help the community? If you still need assistance you can repost your second question in the community so that it will be at the top of the feed for the Quicksight experts!