Home > Net >  aws cloudformation describe-stacks --query
aws cloudformation describe-stacks --query

Time:01-26

I am trying to write a query for a specific stack. It looks like this:

$ aws cloudformation describe-stacks --region $AWS_REGION --profile $AWS_PROFILE --stack-name MyStack --query 'Stacks[?StackName == "MyStack"]'
[]

As you can see the output is an empty array. On the other hand:

$ aws cloudformation describe-stacks --region $AWS_REGION --profile $AWS_PROFILE --stack-name MyStack --query 'Stacks[0]'
{
   // the output
}

What am I missing in my query version? How do I fix it?

CodePudding user response:

Enclose the value in backquotes:

--query 'Stacks[?StackName == `MyStack`]'

Filtering AWS CLI output - AWS Command Line Interface

  • Related