Q:

Searching AWS AutoScalingGroup resources by tags

I'm searching for autoscaling groups by tags - all of our AWS resources have a number of tags applied to them.  However I only want to find auto scaling groups, not other types of resources. 
The should be possible using the tagging API; from the command-line:
aws resourcegroupstaggingapi get-resources --resource-type-filters=autoscaling

However, this results in the error: Unsupported service=autoscaling in ResourceTypeFilter.  It works fine for other resource type filters such as ec2. 
(Note that providing the more specific --resource-type-filters=autoscaling:autoScalingGroup results in the same error)
I've also noticed that if I actually search for tags without restricting the resource type to autoscaling, I do not get any autoscaling group ARNs in the response. 
Is there any (other) way to search for auto scaling groups by tags in the AWS APIs? 

The reason is that I want to create custom metrics for a range of services and I need to find the correct auto scaling groups by a specific set of tags, to be able to retrieve and put CloudWatch metrics with the AutoScalingGroupName metric dimension for each. 

A:

Unfortunately you can't use aws recourcegroupstaggingapi simply because this API doesn't support AutoScaling Groups at the moment.  That's also why AutoScaling info is not returned in get-resources results as you noticed.  See Resource Groups Tagging » API Reference for the actual API and supported resources.  Note that AutoScaling is not part of the EC2 API.  Why this limitation?  I don't know, you'll have to ask Amazon ;)
However with a bit bit of jq hackery you can use aws autoscaling describe-auto-scaling-groups as a workaround:
~ $ aws autoscaling describe-auto-scaling-groups | jq -r '
        ## Unfold .Tags[] to .TagKey = Value
        .[keys[0]] | map(
            if has("Tags") then 
                .  += (.Tags | map( { "Tag\(.Key)": (.Value) } ) | add | del(.Tags))
            else
                . 
            end
        )[] | 
        ## TagKey == Value you want to select on (e.g. Name=="wiki-3" in my case)
        select(.TagName == "wiki-3") |
        ## The attribute you want to output (e.g. .AutoScalingGroupName or .AutoScalingGroupARN)
        .AutoScalingGroupName
'

Hope that helps :)

