Open
Description
Describe the bug
The information from the data element nsxt_policy_segment_realization is not displayed via the output element
Reproduction steps
- terraform init
- terraform plan
data.nsxt_policy_mac_discovery_profile.nsx_mac_discovery_profile: Reading...
data.nsxt_policy_transport_zone.vlan_tz: Reading...
data.nsxt_policy_transport_zone.overlay_tz: Reading...
data.nsxt_policy_segment_security_profile.nsx_security_profile: Reading...
data.nsxt_policy_mac_discovery_profile.nsx_mac_discovery_profile: Read complete after 0s [id=<removed>]
data.nsxt_policy_segment_security_profile.nsx_security_profile: Read complete after 0s [id=<removed>]
data.nsxt_policy_transport_zone.overlay_tz: Read complete after 0s [id=<removed>]
data.nsxt_policy_transport_zone.vlan_tz: Read complete after 0s [id=<removed>]
Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
+ create
<= read (data resources)
Terraform will perform the following actions:
# data.nsxt_policy_segment_realization.tenant_networks["Test-mgmt"] will be read during apply
# (config refers to values not yet known)
<= data "nsxt_policy_segment_realization" "tenant_networks" {
+ id = (known after apply)
+ network_name = (known after apply)
+ path = (known after apply)
+ state = (known after apply)
}
# nsxt_policy_project.tenant_networks will be created
+ resource "nsxt_policy_project" "tenant_networks" {
+ description = "Terraform provisioned and managed Project"
+ display_name = "test"
+ id = (known after apply)
+ nsx_id = (known after apply)
+ path = (known after apply)
+ revision = (known after apply)
+ short_id = (known after apply)
}
# nsxt_policy_segment.tenant_networks["500"] will be created
+ resource "nsxt_policy_segment" "tenant_networks" {
+ description = "provisioned and managed with Terraform"
+ display_name = "Test-mgmt"
+ id = (known after apply)
+ nsx_id = (known after apply)
+ overlay_id = (known after apply)
+ path = (known after apply)
+ replication_mode = "MTEP"
+ revision = (known after apply)
+ transport_zone_path = "/infra/sites/default/enforcement-points/default/transport-zones/<removed>"
+ discovery_profile {
+ binding_map_path = (known after apply)
+ mac_discovery_profile_path = "/infra/mac-discovery-profiles/<removed>"
+ revision = (known after apply)
}
+ security_profile {
+ binding_map_path = (known after apply)
+ revision = (known after apply)
+ security_profile_path = "/infra/segment-security-profiles/<removed>"
}
}
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ network = {
+ Test-mgmt = {
+ context = []
}
}
─────────────────────────────────────────────────────────────────────────────────────────────────────────
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly
these actions if you run "terraform apply" now.
- output ist empty
...
Expected behavior
The complete variable information from the data element is displayed.
So something like this:
Changes to Outputs:
+ network = {
+ Test-mgmt = {
+ id = (known after apply)
+ network_name = (known after apply)
+ path = (known after apply)
+ state = (known after apply)
}
}
Additional context
Config:
main.tf
data "nsxt_policy_transport_zone" "overlay_tz" {
display_name = var.nsx.transport_zone.overlay
}
data "nsxt_policy_transport_zone" "vlan_tz" {
display_name = var.nsx.transport_zone.vlan
}
data "nsxt_policy_mac_discovery_profile" "nsx_mac_discovery_profile" {
display_name = var.nsx.mac_discovery_profile
}
data "nsxt_policy_segment_security_profile" "nsx_security_profile" {
display_name = var.nsx.security_profile
}
resource "nsxt_policy_segment" "tenant_networks" {
for_each = { for network in var.networks : network.id => network}
display_name = "${each.value.name}"
description = "provisioned with Terraform"
transport_zone_path = "${data.nsxt_policy_transport_zone.overlay_tz.path}"
discovery_profile {
mac_discovery_profile_path = "${data.nsxt_policy_mac_discovery_profile.nsx_mac_discovery_profile.path}"
}
security_profile {
security_profile_path = "${data.nsxt_policy_segment_security_profile.nsx_security_profile.path}"
}
}
data "nsxt_policy_segment_realization" "tenant_networks" {
for_each = { for network in var.networks : network.name => network}
path = resource.nsxt_policy_segment.tenant_networks["${each.value.id}"].path
depends_on = [resource.nsxt_policy_segment.tenant_networks]
}
output "network" {
value = data.nsxt_policy_segment_realization.tenant_networks
}
var.tf
variable "nsx" {
type = object({
ip_address = string
username = string
password = string
transport_zone = object({
overlay = string
vlan = string
edge = optional(string)
})
mac_discovery_profile = string
security_profile = string
})
sensitive = true
}
variable "networks" {
type = list(object({
name = string
id = number
}))
}
provider.tf
terraform {
required_providers {
nsxt = {
source = "vmware/nsxt"
version = "3.4.0"
configuration_aliases = [
nsxt,
]
}
}
}
Testdata:
terraform.tfvars
nsx = {
ip_address = "<nsx_address>"
username = "<nsx_username>"
password = "<nsx_password>"
transport_zone = {
overlay = "<nsx_overlay>"
vlan = "<nsx_vlan>"
}
mac_discovery_profile = "<nsx_mac_discovery_profile>"
security_profile = "<nsx_security_profile>"
}
tenant_networks = [
{
name = "Test-mgmt"
id = 500
}
]