2

What query should I use to get all CloudFormation stacks that start with a specific string?

I have tried the following query, but it always returns an empty array:

aws cloudformation describe-stacks --no-paginate --query "Stacks[?StackName!='null']|[?starts_with(StackName,'HD-') == 'true']"

All the stacks in our account start with "HD-", so this should return the same as

aws cloudformation describe-stacks --no-paginate

But it returns

[]
Kappacake
  • 1,826
  • 19
  • 38

1 Answers1

6

This command works fine:

aws cloudformation describe-stacks --no-paginate --query \
  'Stacks[?StackName!=`null`]|[?contains(StackName, `Release`) == `true`].StackName'

It looks like you need to use ` rather than ' inside the query..

Alex Harvey
  • 14,494
  • 5
  • 61
  • 97
Kappacake
  • 1,826
  • 19
  • 38