From 44fb89f9d93bf40d9ddc32b6e57f7990b9d0fbb9 Mon Sep 17 00:00:00 2001 From: Anna Khmelnitsky Date: Tue, 9 Mar 2021 02:38:06 +0000 Subject: [PATCH] Dont assign VRF route targets unless specified VrfRouteTargets needs to be allocated only if targets are specified, otherwise realization for VRF gateway may fail. --- nsxt/resource_nsxt_policy_tier0_gateway.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nsxt/resource_nsxt_policy_tier0_gateway.go b/nsxt/resource_nsxt_policy_tier0_gateway.go index 2e17ec8d5..82931b85a 100644 --- a/nsxt/resource_nsxt_policy_tier0_gateway.go +++ b/nsxt/resource_nsxt_policy_tier0_gateway.go @@ -454,13 +454,15 @@ func getPolicyVRFConfigFromSchema(d *schema.ResourceData) *model.Tier0VrfConfig exportTargets := interface2StringList(routeTarget["export_targets"].([]interface{})) importTargets := interface2StringList(routeTarget["import_targets"].([]interface{})) // Only one is supported for now - targets := model.VrfRouteTargets{ - AddressFamily: &addressFamily, - ExportRouteTargets: exportTargets, - ImportRouteTargets: importTargets, - } + if len(exportTargets)+len(importTargets) > 0 { + targets := model.VrfRouteTargets{ + AddressFamily: &addressFamily, + ExportRouteTargets: exportTargets, + ImportRouteTargets: importTargets, + } - config.RouteTargets = []model.VrfRouteTargets{targets} + config.RouteTargets = []model.VrfRouteTargets{targets} + } } if vni > 0 {