bhargav joshi
bhargav joshi

Reputation: 482

AWS-CLI: How do I filter autoscalinggroups

Unable to find example to use filters https://docs.aws.amazon.com/cli/latest/reference/autoscaling/describe-auto-scaling-groups.html#options

Upvotes: 0

Views: 2634

Answers (3)

arun Kaliappan
arun Kaliappan

Reputation: 143

I tried the same without double quotes with the filters, and it worked.

aws autoscaling describe-auto-scaling-groups --filters Name=tag:\eks:nodegroup-name\,Values=cassandra

Upvotes: 0

azbarcea
azbarcea

Reputation: 3657

Try something like:

aws ec2 describe-instances --filters "Name=tag:Name,Values=xxx" "Name=tag:env,Values=dev"

more

UPDATE: I believe you need the tag: or tag-key: per the error message you provided, as in the example above: The filter criteria isn't valid. Valid filter types for the Name attribute of filters are: tag-key, tag-value and tag:<key>. The confusing part is that your tag has the : (COLON) character (more), which either needs escaped or not used or replaced.

aws autoscaling describe-auto-scaling-groups --filters "Name=tag:\"eks:nodegroup-name\",Values=cassandra"

Upvotes: 1

OARP
OARP

Reputation: 4077

Try with the following command:

aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`eks:nodegroup-name`].Value, `cassandra`)]' --region [AWS_REGION]

Or if you only want the ASG name you can filter it using:

aws autoscaling describe-auto-scaling-groups --query 'AutoScalingGroups[?contains(Tags[?Key==`eks:nodegroup-name`].Value, `cassandra`)].[AutoScalingGroupName]' --region [AWS_REGION]

Reference:

Filtering AWS CLI output

Upvotes: 0

Related Questions