Search code examples
amazon-web-servicesaws-cli

Get target group arn from aws cli


I'm trying to get the arn of a target group that contains the word test or the value assigned to "value" in its name, but I can't get it, I got this error.

value=test
aws elbv2 describe-target-groups --query "TargetGroups[?starts_with(TargetGroupName, '${value}') == `true`].[TargetGroupArn]"
Bad value for --query TargetGroups[?starts_with(TargetGroupName, 'test') == ].[TargetGroupArn]: invalid token: Parse error at column 59, token "]" (RBRACKET), for expression:
"TargetGroups[?starts_with(TargetGroupName, 'test') == ].[TargetGroupArn]"
                                                       ^

I am using bash on windows


Solution

  • Looks like you've used backticks around your true value:

    `true`
    

    try replacing them with single-quotes instead.

    'true'