@@ -43,7 +43,7 @@ func resourceNsxtPolicyL2VPNSession() *schema.Resource {
4343 Update : resourceNsxtPolicyL2VPNSessionUpdate ,
4444 Delete : resourceNsxtPolicyL2VPNSessionDelete ,
4545 Importer : & schema.ResourceImporter {
46- State : nsxtVpnSessionImporter ,
46+ State : nsxtL2VpnSessionImporter ,
4747 },
4848
4949 Schema : map [string ]* schema.Schema {
@@ -387,6 +387,30 @@ func resourceNsxtPolicyL2VPNSessionUpdate(d *schema.ResourceData, m interface{})
387387
388388}
389389
390+ func nsxtL2VpnSessionImporter (d * schema.ResourceData , m interface {}) ([]* schema.ResourceData , error ) {
391+ importID := d .Id ()
392+ err := fmt .Errorf ("Expected L2 VPN session path, got %s" , importID )
393+ // Path should be like /infra/tier-1s/aaa/locale-services/default/l2vpn-services/bbb/sessions/ccc
394+ s := strings .Split (importID , "/" )
395+ if len (s ) < 8 {
396+ return []* schema.ResourceData {d }, err
397+ }
398+
399+ d .SetId (s [len (s )- 1 ])
400+
401+ s = strings .Split (importID , "/sessions/" )
402+ if len (s ) != 2 {
403+ return []* schema.ResourceData {d }, err
404+ }
405+ d .Set ("service_path" , s [0 ])
406+
407+ // L2 VPN sessions are infra-scoped only; project context is not supported.
408+ if extractProjectIDFromPolicyPath (importID ) != "" {
409+ return nil , fmt .Errorf ("L2 VPN sessions do not support project context; import path must be infra-scoped (e.g. /infra/tier-1s/...)" )
410+ }
411+ return []* schema.ResourceData {d }, nil
412+ }
413+
390414func resourceNsxtPolicyL2VPNSessionDelete (d * schema.ResourceData , m interface {}) error {
391415
392416 servicePath := d .Get ("service_path" ).(string )
0 commit comments