When using aws_autoscaling_group as a data source, I expect to be able to filter autoscaling groups similar to how I can filter other resource (i.e. aws_ami).
Any
aws_autoscaling_groups
data "aws_autoscaling_groups" "asgs" {
filter {
name = "tag:some-arbitrary-tag"
values = ["some-arbitrary-value", "some-other-arbitrary-value"]
}
}
Finds AutoScaling groups that have a tag with a key some-arbitrary-value and either some-arbitrary-value or some-other-arbitrary-value as values.
This behavior isn't supported.
I spent a little time seeing if I could implement this behavior myself. I can see why this isn't currently supported :). The data provider (terraform-provider-aws/aws/data_source_aws_autoscaling_groups.go) basically just encapsulates the behavior of the AWS SDK's DescribeTags() functionality, which means this data source isn't doing what we (users) would intuitively expect. I see two possible routes to fix this:
Option 1 is probably the way to solve the issue fastest, but the real problem is that the SDK doesn't easily support the desired behavior, so option 2 is probably the correct solution. Perhaps we implement a temporary workaround, while looking at how we can improve the SDK to better suit this behavior?
Anyway, I'd be willing to help on this issue of the team provides some feedback on the proper approach.
this might take a while, as the raw API does not support filters, so AWS will need to update their API endpoint first, before the SDK's can be updated.
A good source for this is the raw API doc's for AWS's API
https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_DescribeAutoScalingGroups.html
@madmax88 it is using the describe tags function, looks like it needs some debugging. if I get time will take a look.
This issue is pretty old but the data source supports filters now... however, it only seems to support one tag filter at a time, or maybe it is ORing them together. If you try to do something like filter on Role=myapp, Environment=qa you get everything from Environment=qa and everything from Role=myapp. This is not how filters normally work in AWS I think, I mean if you use the console to filter it ANDs the filters together
Most helpful comment
This issue is pretty old but the data source supports filters now... however, it only seems to support one tag filter at a time, or maybe it is ORing them together. If you try to do something like filter on Role=myapp, Environment=qa you get everything from Environment=qa and everything from Role=myapp. This is not how filters normally work in AWS I think, I mean if you use the console to filter it ANDs the filters together