diff --git a/nsxt/resource_nsxt_policy_gateway_route_map.go b/nsxt/resource_nsxt_policy_gateway_route_map.go index 364a10b75..00aec105d 100644 --- a/nsxt/resource_nsxt_policy_gateway_route_map.go +++ b/nsxt/resource_nsxt_policy_gateway_route_map.go @@ -103,7 +103,7 @@ func getPolicyRouteMapEntrySchema() *schema.Resource { "as_path_prepend": { Type: schema.TypeString, Optional: true, - ValidateFunc: validateASPlainOrDot, + ValidateFunc: validateASPath, Description: "Autonomous System (AS) path prepend to influence route selection", }, "community": { diff --git a/nsxt/resource_nsxt_policy_gateway_route_map_test.go b/nsxt/resource_nsxt_policy_gateway_route_map_test.go index b2141120d..373494fb0 100644 --- a/nsxt/resource_nsxt_policy_gateway_route_map_test.go +++ b/nsxt/resource_nsxt_policy_gateway_route_map_test.go @@ -173,7 +173,7 @@ resource "nsxt_policy_gateway_route_map" "test" { } set { - as_path_prepend = "12.998" + as_path_prepend = "100 100" community = "11:22" local_preference = 1122 med = 120 diff --git a/nsxt/validators.go b/nsxt/validators.go index 4e13b1ba6..b0e1c7908 100644 --- a/nsxt/validators.go +++ b/nsxt/validators.go @@ -503,6 +503,21 @@ func validateASPlainOrDot(i interface{}, k string) (s []string, es []error) { return } +func validateASPath(i interface{}, k string) (s []string, es []error) { + v, ok := i.(string) + if !ok { + es = append(es, fmt.Errorf("String is expected, got %s", v)) + return + } + + tokens := strings.Split(v, " ") + for _, token := range tokens { + s, es = validateASPlainOrDot(token, k) + } + + return +} + func validatePolicyBGPCommunity(i interface{}, k string) (s []string, es []error) { v, ok := i.(string) if !ok {