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

New data source that returns multiple VMs #446

Closed
neil-wwt opened this issue Sep 2, 2020 · 2 comments
Closed

New data source that returns multiple VMs #446

neil-wwt opened this issue Sep 2, 2020 · 2 comments
Assignees
Labels
enhancement Enhancement

Comments

@neil-wwt
Copy link

neil-wwt commented Sep 2, 2020

The current data source for VMs (nsxt_policy_vm) only allows for returning attributes about a single VM.

It would be really useful if there was a data source that returned a list of VMs similar to the aws_instances data source.

The arguments for this data source would need more capabilities like pattern matching or filters of course.

Suggested Example

data "nsxt_policy_vms" "ubuntu_vms" {
  filter {
    OS = "Ubuntu"
    display_name = "web*"
  }
}

This would return all VMs with an Ubuntu OS and a name that starts with web (regex patterns would be really great here)

Then from this you could do something like apply a tag to each VM using its instance ID

resource "nsxt_policy_vm_tags" "web_servers" {
  for_each = data.nsxt_policy_vms.ubuntu_vms.instance_ids
  instance_id = each.value

  tag {
    tag   = "Web"
  }
}
@annakhm annakhm added the enhancement Enhancement label Sep 3, 2020
@github-actions
Copy link

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

@github-actions github-actions bot added the stale Stale label Aug 29, 2021
@annakhm annakhm removed the stale Stale label Apr 3, 2023
@annakhm annakhm reopened this Apr 3, 2023
@annakhm annakhm self-assigned this Apr 6, 2023
@annakhm
Copy link
Collaborator

annakhm commented Apr 28, 2023

Filtering by state and guest_os was added for nsxt_policy_vms in #869
Sorry it took such a long time!

@annakhm annakhm closed this as completed Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement
Projects
None yet
Development

No branches or pull requests

2 participants