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

Include ability to filter images based on labels or other data. #3442

Closed
amy-hashi opened this issue Apr 16, 2019 · 4 comments · Fixed by GoogleCloudPlatform/magic-modules#4026, hashicorp/terraform-provider-google-beta#2573 or #7488

Comments

@amy-hashi
Copy link

amy-hashi commented Apr 16, 2019

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment. If the issue is assigned to the "modular-magician" user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If the issue is assigned to a user, that user is claiming responsibility for the issue. If the issue is assigned to "hashibot", a community member has claimed the issue already.

Description

Both the aws and azure providers already offer something similar (azure name regex and aws filter).

Ideally you'd be able to filter based on name, label, image family, region, etc.

New or Affected Resource(s)

Potential Terraform Configuration

# Propose what you think the configuration to take advantage of this feature should look like.
# We may not use it verbatim, but it's helpful in understanding your intent.
data "google_compute_image" "my_image" {
  name    = "debian-9"
  project = "debian-cloud"

  filter {
    name = "label"
    values = ["label1-*"]
  }

  filter {
    name = "region"
    values = ["uswest"]
  }
}

References

  • #0000
@ghost ghost added the enhancement label Apr 16, 2019
@paddycarver paddycarver added this to the Goals milestone Dec 10, 2019
@megan07 megan07 modified the milestones: Goals, Near-Term Goals Mar 20, 2020
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Jul 30, 2020
modular-magician added a commit that referenced this issue Jul 30, 2020
dboshardy pushed a commit to dboshardy/terraform-provider-google that referenced this issue Aug 3, 2020
* upstream/master:
  Add a random string to ad directory so tests can be run in parallel (hashicorp#3802) (hashicorp#6905)
  Set context early on in LoadAndValidate to prevent NPE (hashicorp#3800) (hashicorp#6903)
  Add tests for DICOM store pubsub topic removal. (hashicorp#3442) (hashicorp#6893)
  Bump Bigtable version from 1.1.0 to 1.5.0 (hashicorp#6890)
  Fix colon in doc notes (hashicorp#3796) (hashicorp#6888)
  Fix bug: diff being detected for source_repo_repository even when there are no changes (hashicorp#3786) (hashicorp#6886)
  Use proper prefix inside router_interface test (hashicorp#3795) (hashicorp#6883)
  Update Bigtable Num of Clusters Block Docs (hashicorp#3792) (hashicorp#6881)
@upodroid
Copy link
Contributor

@danawillow Can we close this issue? this feature is not needed for GCE Images.

  1. https://cloud.google.com/compute/docs/reference/rest/beta/images/getFromFamily and https://cloud.google.com/compute/docs/reference/rest/beta/images/get API Calls return exactly one image from Google so there is no point in filtering the response. Images are globally unique within a project.
  2. The OP referred to filters in aws_ami but AWS has a clunky implementation for this (biased 😄 ). https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/data_source_aws_ami.go#L205 and https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html . That API call returns a list of images that need to be filtered.

@danawillow
Copy link
Contributor

@upodroid, I think the request is to be able to get a list of images that specify certain conditions, so that the user doesn't have to know the name of the image in order to use it. That seems totally reasonable to me. This would be using https://cloud.google.com/compute/docs/reference/rest/beta/images/list instead of get or getFromFamily. Given the 25 👍 on this issue, it seems like this is something that people are looking for outside of what the provider currently offers, even if it isn't useful to you, so I'd prefer not to close it.

@upodroid
Copy link
Contributor

In that case, I can implement the list method when no name or family is provided and use the filter query params to supply user filters. Like the aws_ami datasource, the filters provided must return a single image or an error is returned.

@ghost
Copy link

ghost commented Nov 9, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.