Search code examples
amazon-web-servicesaws-cliamazon-ecr

Amazon aws cli query starts_with


Trying to filter out only repos that start with name but always got empty collection back. I can see the values there when running without the starts_with option

aws ecr describe-repositories --query "repositories[?starts_with(repositoryName, 'test') == 'true'].repositoryName"

Solution

  • You need to use Backticks for pattern matching.

    aws ecr describe-repositories --query 'repositories[?starts_with(repositoryName, `stage`) == `true`]' 
    

    or If you want just ARN or NAME then you can use

    
    aws ecr describe-repositories --query 'repositories[?starts_with(repositoryName, `stage`) == `true`]|[].[repositoryName,repositoryUri]'