diff --git a/nsxt/policy_common.go b/nsxt/policy_common.go index eb39b4d70..74b4ad73c 100644 --- a/nsxt/policy_common.go +++ b/nsxt/policy_common.go @@ -559,9 +559,7 @@ func buildQueryStringFromMap(query map[string]string) string { } keyValues := make([]string, 0, len(query)) for key, value := range query { - if strings.Contains(value, "/") { - value = strings.Replace(value, "/", "\\/", -1) - } + value = strings.Replace(value, "/", "\\/", -1) keyValue := strings.Join([]string{key, value}, ":") keyValues = append(keyValues, keyValue) } diff --git a/nsxt/resource_nsxt_policy_gateway_route_map.go b/nsxt/resource_nsxt_policy_gateway_route_map.go index 4fc62ac90..364a10b75 100644 --- a/nsxt/resource_nsxt_policy_gateway_route_map.go +++ b/nsxt/resource_nsxt_policy_gateway_route_map.go @@ -198,14 +198,18 @@ func policyGatewayRouteMapBuildEntry(schemaEntry map[string]interface{}) model.R weight := int64(data["weight"].(int)) entrySet := model.RouteMapEntrySet{ - AsPathPrepend: &asPathPrepend, - Community: &community, LocalPreference: &localPreference, Med: &med, PreferGlobalV6NextHop: &globalIPv6, Weight: &weight, } + if len(asPathPrepend) > 0 { + entrySet.AsPathPrepend = &asPathPrepend + } + if len(community) > 0 { + entrySet.Community = &community + } obj.Set = &entrySet } diff --git a/website/docs/r/policy_gateway_route_map.html.markdown b/website/docs/r/policy_gateway_route_map.html.markdown index 9d374fb06..90eb77bdb 100644 --- a/website/docs/r/policy_gateway_route_map.html.markdown +++ b/website/docs/r/policy_gateway_route_map.html.markdown @@ -23,12 +23,12 @@ resource "nsxt_policy_gateway_route_map" "test" { action = "PERMIT" community_list_match { criteria = "11:*" - match_operator = "MATCH_COMMUNITY_REGEX" + match_operator = "COMMUNITY_REGEX" } community_list_match { criteria = "11:*" - match_operator = "MATCH_LARGE_COMMUNITY_REGEX" + match_operator = "LARGE_COMMUNITY_REGEX" } }