The nsxt_vpc_group resource manages inventory Groups and their members within a VPC scope. These groups are commonly used as sources, destinations, or in the 'Applied To' field of firewall rules. This resource is compatible with NSX Policy Manager and requires NSX 9.0.0 or later.
To use this resource, you must provide a context block containing the project_id and vpc_id of the target VPC. Membership can be defined using various criteria blocks, such as IP addresses, MAC addresses, policy paths, external IDs, or attribute-based conditions (e.g., filtering by OS name or VM name).
data "nsxt_policy_project" "demoproj" {
display_name = "demoproj"
}
data "nsxt_vpc" "demovpc" {
context {
project_id = data.nsxt_policy_project.demoproj.id
}
display_name = "vpc1"
}
resource "nsxt_vpc_group" "group1" {
context {
project_id = data.nsxt_policy_project.demoproj.id
vpc_id = data.nsxt_vpc.demovpc.id
}
display_name = "tf-group1"
description = "Terraform provisioned Group"
criteria {
condition {
key = "Name"
member_type = "VirtualMachine"
operator = "STARTSWITH"
value = "public"
}
condition {
key = "OSName"
member_type = "VirtualMachine"
operator = "CONTAINS"
value = "Ubuntu"
}
}
}