Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve filters for data source aws_autoscaling_group #3534

Closed
obicons opened this issue Feb 26, 2018 · 6 comments · Fixed by #21966
Closed

Improve filters for data source aws_autoscaling_group #3534

obicons opened this issue Feb 26, 2018 · 6 comments · Fixed by #21966
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Milestone

Comments

@obicons
Copy link

obicons commented Feb 26, 2018

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).

Terraform Version

Any

Affected Resource(s)

aws_autoscaling_groups

Terraform Configuration Files

data "aws_autoscaling_groups" "asgs" {
  filter {
    name = "tag:some-arbitrary-tag"
    values = ["some-arbitrary-value", "some-other-arbitrary-value"]
  }
}

Expected Behavior

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.

Actual Behavior

This behavior isn't supported.

Preliminary Findings

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:

  1. Increase the complexity of the data source by implementing the desired behavior
  2. Cooperate with Amazon to improve the quality of the SDK in this instance

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.

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service. labels Feb 27, 2018
@richardbowden
Copy link
Contributor

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

@richardbowden
Copy link
Contributor

richardbowden commented Feb 27, 2018

@MadMax88 it is using the describe tags function, looks like it needs some debugging. if I get time will take a look.

@2rs2ts
Copy link
Contributor

2rs2ts commented Jun 20, 2019

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: if you use the console to filter, it ANDs the filters together

@hegyre
Copy link

hegyre commented Oct 18, 2021

Tags are now natively supported by the API:
https://aws.amazon.com/about-aws/whats-new/2021/10/amazon-ec2-auto-scaling-groups-using-tags/

@github-actions
Copy link

github-actions bot commented Dec 2, 2021

This functionality has been released in v3.68.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants