Everything looks right, and pasting the "echo" output into the aws command works as expected. However, when using the variables on the command line, aws complains about an unclosed delimiter, even though there is (or at least seems to be) a terminating delimiter.
QF1="'DBInstances[*].[DBInstanceIdentifier, "
QF2="SecondaryAvailabilityZone]'"
echo ${QF1}${QF2}
'DBInstances[*].[DBInstanceIdentifier, SecondaryAvailabilityZone]'
$ aws rds describe-db-instances
--query 'DBInstances[*].[DBInstanceIdentifier, SecondaryAvailabilityZone]'
--output=table
| DescribeDBInstances |
+--------------------------+--------------+
| copy-20210720 | None |
| uis-clitst-rds-east-db1 | None |
| uis-dev-rds-east-db1 | None |
| uis-intst-rds-east-db1 | us-east-1c |
| uis-prod-rds-east-db1 | us-east-1b |
+--------------------------+--------------+
aws rds describe-db-instances --query ${QF1}${QF2}
Bad value for --query 'DBInstances[*].[DBInstanceIdentifier,: Bad jmespath expression: Unclosed ' delimiter:
'DBInstances[*].[DBInstanceIdentifier,
^
'DBInstances[*].[DBInstanceIdentifier,
. (Also, tryecho foo bar
) – ilkkachu Jul 21 '21 at 18:40