1. Packages
  2. Packages
  3. Nsxt Provider
  4. API Docs
  5. getPolicySegmentPorts
Viewing docs for nsxt 3.12.0
published on Monday, May 18, 2026 by vmware
Viewing docs for nsxt 3.12.0
published on Monday, May 18, 2026 by vmware

    This data source provides a method for retrieving multiple Segment Ports based on filter criteria. Unlike the singular nsxt.PolicySegmentPort data source, this returns a list of segment ports matching the specified filters.

    Example Usage

    Get all segment ports for a specific segment

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const segment1 = nsxt.getPolicySegment({
        displayName: "segment1",
    });
    const allPorts = segment1.then(segment1 => nsxt.getPolicySegmentPorts({
        segmentPath: segment1.path,
    }));
    export const portCount = allPorts.then(allPorts => allPorts.items).length;
    export const firstPortId = allPorts.then(allPorts => allPorts.items?.[0]?.id);
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    segment1 = nsxt.get_policy_segment(display_name="segment1")
    all_ports = nsxt.get_policy_segment_ports(segment_path=segment1.path)
    pulumi.export("portCount", len(all_ports.items))
    pulumi.export("firstPortId", all_ports.items[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		segment1, err := nsxt.LookupPolicySegment(ctx, &nsxt.LookupPolicySegmentArgs{
    			DisplayName: pulumi.StringRef("segment1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		allPorts, err := nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			SegmentPath: pulumi.StringRef(segment1.Path),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("portCount", len(allPorts.Items))
    		ctx.Export("firstPortId", allPorts.Items[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var segment1 = Nsxt.GetPolicySegment.Invoke(new()
        {
            DisplayName = "segment1",
        });
    
        var allPorts = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            SegmentPath = segment1.Apply(getPolicySegmentResult => getPolicySegmentResult.Path),
        });
    
        return new Dictionary<string, object?>
        {
            ["portCount"] = allPorts.Apply(getPolicySegmentPortsResult => getPolicySegmentPortsResult.Items).Length,
            ["firstPortId"] = allPorts.Apply(getPolicySegmentPortsResult => getPolicySegmentPortsResult.Items[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var segment1 = NsxtFunctions.getPolicySegment(GetPolicySegmentArgs.builder()
                .displayName("segment1")
                .build());
    
            final var allPorts = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .segmentPath(segment1.path())
                .build());
    
            ctx.export("portCount", allPorts.items().length());
            ctx.export("firstPortId", allPorts.items()[0].id());
        }
    }
    
    Example coming soon!
    
    Example coming soon!
    

    Get segment ports by segment path and display name

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const segment1 = nsxt.getPolicySegment({
        displayName: "segment1",
    });
    const filteredPorts = segment1.then(segment1 => nsxt.getPolicySegmentPorts({
        segmentPath: segment1.path,
        displayName: "web-server-port",
    }));
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    segment1 = nsxt.get_policy_segment(display_name="segment1")
    filtered_ports = nsxt.get_policy_segment_ports(segment_path=segment1.path,
        display_name="web-server-port")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		segment1, err := nsxt.LookupPolicySegment(ctx, &nsxt.LookupPolicySegmentArgs{
    			DisplayName: pulumi.StringRef("segment1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			SegmentPath: pulumi.StringRef(segment1.Path),
    			DisplayName: pulumi.StringRef("web-server-port"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var segment1 = Nsxt.GetPolicySegment.Invoke(new()
        {
            DisplayName = "segment1",
        });
    
        var filteredPorts = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            SegmentPath = segment1.Apply(getPolicySegmentResult => getPolicySegmentResult.Path),
            DisplayName = "web-server-port",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var segment1 = NsxtFunctions.getPolicySegment(GetPolicySegmentArgs.builder()
                .displayName("segment1")
                .build());
    
            final var filteredPorts = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .segmentPath(segment1.path())
                .displayName("web-server-port")
                .build());
    
        }
    }
    
    variables:
      segment1:
        fn::invoke:
          function: nsxt:getPolicySegment
          arguments:
            displayName: segment1
      filteredPorts:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            segmentPath: ${segment1.path}
            displayName: web-server-port
    
    Example coming soon!
    

    Get segment ports by VIF ID

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const byVif = nsxt.getPolicySegmentPorts({
        vifId: "50234567-abcd-1234-5678-123456789abc",
    });
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    by_vif = nsxt.get_policy_segment_ports(vif_id="50234567-abcd-1234-5678-123456789abc")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			VifId: pulumi.StringRef("50234567-abcd-1234-5678-123456789abc"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var byVif = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            VifId = "50234567-abcd-1234-5678-123456789abc",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var byVif = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .vifId("50234567-abcd-1234-5678-123456789abc")
                .build());
    
        }
    }
    
    variables:
      byVif:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            vifId: 50234567-abcd-1234-5678-123456789abc
    
    Example coming soon!
    

    Get segment ports by VIF ID and display name

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    // This will first filter by VIF ID, then filter the results by display name
    const byVifAndName = nsxt.getPolicySegmentPorts({
        vifId: "50234567-abcd-1234-5678-123456789abc",
        displayName: "web-server-port",
    });
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    # This will first filter by VIF ID, then filter the results by display name
    by_vif_and_name = nsxt.get_policy_segment_ports(vif_id="50234567-abcd-1234-5678-123456789abc",
        display_name="web-server-port")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// This will first filter by VIF ID, then filter the results by display name
    		_, err := nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			VifId:       pulumi.StringRef("50234567-abcd-1234-5678-123456789abc"),
    			DisplayName: pulumi.StringRef("web-server-port"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        // This will first filter by VIF ID, then filter the results by display name
        var byVifAndName = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            VifId = "50234567-abcd-1234-5678-123456789abc",
            DisplayName = "web-server-port",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            // This will first filter by VIF ID, then filter the results by display name
            final var byVifAndName = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .vifId("50234567-abcd-1234-5678-123456789abc")
                .displayName("web-server-port")
                .build());
    
        }
    }
    
    variables:
      # This will first filter by VIF ID, then filter the results by display name
      byVifAndName:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            vifId: 50234567-abcd-1234-5678-123456789abc
            displayName: web-server-port
    
    Example coming soon!
    

    Get segment ports by VIF ID and segment path

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const segment1 = nsxt.getPolicySegment({
        displayName: "segment1",
    });
    // This will filter by both VIF ID and segment path
    const byVifAndSegment = segment1.then(segment1 => nsxt.getPolicySegmentPorts({
        vifId: "50234567-abcd-1234-5678-123456789abc",
        segmentPath: segment1.path,
    }));
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    segment1 = nsxt.get_policy_segment(display_name="segment1")
    # This will filter by both VIF ID and segment path
    by_vif_and_segment = nsxt.get_policy_segment_ports(vif_id="50234567-abcd-1234-5678-123456789abc",
        segment_path=segment1.path)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		segment1, err := nsxt.LookupPolicySegment(ctx, &nsxt.LookupPolicySegmentArgs{
    			DisplayName: pulumi.StringRef("segment1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// This will filter by both VIF ID and segment path
    		_, err = nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			VifId:       pulumi.StringRef("50234567-abcd-1234-5678-123456789abc"),
    			SegmentPath: pulumi.StringRef(segment1.Path),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var segment1 = Nsxt.GetPolicySegment.Invoke(new()
        {
            DisplayName = "segment1",
        });
    
        // This will filter by both VIF ID and segment path
        var byVifAndSegment = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            VifId = "50234567-abcd-1234-5678-123456789abc",
            SegmentPath = segment1.Apply(getPolicySegmentResult => getPolicySegmentResult.Path),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var segment1 = NsxtFunctions.getPolicySegment(GetPolicySegmentArgs.builder()
                .displayName("segment1")
                .build());
    
            // This will filter by both VIF ID and segment path
            final var byVifAndSegment = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .vifId("50234567-abcd-1234-5678-123456789abc")
                .segmentPath(segment1.path())
                .build());
    
        }
    }
    
    variables:
      segment1:
        fn::invoke:
          function: nsxt:getPolicySegment
          arguments:
            displayName: segment1
      # This will filter by both VIF ID and segment path
      byVifAndSegment:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            vifId: 50234567-abcd-1234-5678-123456789abc
            segmentPath: ${segment1.path}
    
    Example coming soon!
    

    Get segment ports by display name only

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    // When only display_name is provided, behaves like the singular data source
    const byName = nsxt.getPolicySegmentPorts({
        displayName: "web-server-port",
    });
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    # When only display_name is provided, behaves like the singular data source
    by_name = nsxt.get_policy_segment_ports(display_name="web-server-port")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// When only display_name is provided, behaves like the singular data source
    		_, err := nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			DisplayName: pulumi.StringRef("web-server-port"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        // When only display_name is provided, behaves like the singular data source
        var byName = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            DisplayName = "web-server-port",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            // When only display_name is provided, behaves like the singular data source
            final var byName = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .displayName("web-server-port")
                .build());
    
        }
    }
    
    variables:
      # When only display_name is provided, behaves like the singular data source
      byName:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            displayName: web-server-port
    
    Example coming soon!
    

    Multi-Tenancy

    import * as pulumi from "@pulumi/pulumi";
    import * as nsxt from "@pulumi/nsxt";
    
    const demoproj = nsxt.getPolicyProject({
        displayName: "demoproj",
    });
    const segment1 = demoproj.then(demoproj => nsxt.getPolicySegment({
        context: {
            projectId: demoproj.id,
        },
        displayName: "segment1",
    }));
    const ports = Promise.all([demoproj, segment1]).then(([demoproj, segment1]) => nsxt.getPolicySegmentPorts({
        context: {
            projectId: demoproj.id,
        },
        segmentPath: segment1.path,
    }));
    
    import pulumi
    import pulumi_nsxt as nsxt
    
    demoproj = nsxt.get_policy_project(display_name="demoproj")
    segment1 = nsxt.get_policy_segment(context={
            "project_id": demoproj.id,
        },
        display_name="segment1")
    ports = nsxt.get_policy_segment_ports(context={
            "project_id": demoproj.id,
        },
        segment_path=segment1.path)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/nsxt/v3/nsxt"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		demoproj, err := nsxt.LookupPolicyProject(ctx, &nsxt.LookupPolicyProjectArgs{
    			DisplayName: pulumi.StringRef("demoproj"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		segment1, err := nsxt.LookupPolicySegment(ctx, &nsxt.LookupPolicySegmentArgs{
    			Context: nsxt.GetPolicySegmentContext{
    				ProjectId: pulumi.StringRef(demoproj.Id),
    			},
    			DisplayName: pulumi.StringRef("segment1"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = nsxt.GetPolicySegmentPorts(ctx, &nsxt.GetPolicySegmentPortsArgs{
    			Context: nsxt.GetPolicySegmentPortsContext{
    				ProjectId: pulumi.StringRef(demoproj.Id),
    			},
    			SegmentPath: pulumi.StringRef(segment1.Path),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Nsxt = Pulumi.Nsxt;
    
    return await Deployment.RunAsync(() => 
    {
        var demoproj = Nsxt.GetPolicyProject.Invoke(new()
        {
            DisplayName = "demoproj",
        });
    
        var segment1 = Nsxt.GetPolicySegment.Invoke(new()
        {
            Context = new Nsxt.Inputs.GetPolicySegmentContextInputArgs
            {
                ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
            },
            DisplayName = "segment1",
        });
    
        var ports = Nsxt.GetPolicySegmentPorts.Invoke(new()
        {
            Context = new Nsxt.Inputs.GetPolicySegmentPortsContextInputArgs
            {
                ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
            },
            SegmentPath = segment1.Apply(getPolicySegmentResult => getPolicySegmentResult.Path),
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.nsxt.NsxtFunctions;
    import com.pulumi.nsxt.inputs.GetPolicyProjectArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentContextArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsArgs;
    import com.pulumi.nsxt.inputs.GetPolicySegmentPortsContextArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var demoproj = NsxtFunctions.getPolicyProject(GetPolicyProjectArgs.builder()
                .displayName("demoproj")
                .build());
    
            final var segment1 = NsxtFunctions.getPolicySegment(GetPolicySegmentArgs.builder()
                .context(GetPolicySegmentContextArgs.builder()
                    .projectId(demoproj.id())
                    .build())
                .displayName("segment1")
                .build());
    
            final var ports = NsxtFunctions.getPolicySegmentPorts(GetPolicySegmentPortsArgs.builder()
                .context(GetPolicySegmentPortsContextArgs.builder()
                    .projectId(demoproj.id())
                    .build())
                .segmentPath(segment1.path())
                .build());
    
        }
    }
    
    variables:
      demoproj:
        fn::invoke:
          function: nsxt:getPolicyProject
          arguments:
            displayName: demoproj
      segment1:
        fn::invoke:
          function: nsxt:getPolicySegment
          arguments:
            context:
              projectId: ${demoproj.id}
            displayName: segment1
      ports:
        fn::invoke:
          function: nsxt:getPolicySegmentPorts
          arguments:
            context:
              projectId: ${demoproj.id}
            segmentPath: ${segment1.path}
    
    Example coming soon!
    

    Filter Priority

    The data source applies filters in the following priority order:

    1. VIF ID - If vif_id is set, it’s used as the primary filter. Results can be further filtered by segment_path and/or display_name.
    2. Segment Path - If segment_path is set (without vif_id), it filters ports by parent segment. Can be combined with display_name.
    3. Display Name - If only display_name is set, it searches all segment ports by display name.

    Using getPolicySegmentPorts

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getPolicySegmentPorts(args: GetPolicySegmentPortsArgs, opts?: InvokeOptions): Promise<GetPolicySegmentPortsResult>
    function getPolicySegmentPortsOutput(args: GetPolicySegmentPortsOutputArgs, opts?: InvokeOptions): Output<GetPolicySegmentPortsResult>
    def get_policy_segment_ports(context: Optional[GetPolicySegmentPortsContext] = None,
                                 display_name: Optional[str] = None,
                                 id: Optional[str] = None,
                                 segment_path: Optional[str] = None,
                                 vif_id: Optional[str] = None,
                                 opts: Optional[InvokeOptions] = None) -> GetPolicySegmentPortsResult
    def get_policy_segment_ports_output(context: pulumi.Input[Optional[GetPolicySegmentPortsContextArgs]] = None,
                                 display_name: pulumi.Input[Optional[str]] = None,
                                 id: pulumi.Input[Optional[str]] = None,
                                 segment_path: pulumi.Input[Optional[str]] = None,
                                 vif_id: pulumi.Input[Optional[str]] = None,
                                 opts: Optional[InvokeOptions] = None) -> Output[GetPolicySegmentPortsResult]
    func GetPolicySegmentPorts(ctx *Context, args *GetPolicySegmentPortsArgs, opts ...InvokeOption) (*GetPolicySegmentPortsResult, error)
    func GetPolicySegmentPortsOutput(ctx *Context, args *GetPolicySegmentPortsOutputArgs, opts ...InvokeOption) GetPolicySegmentPortsResultOutput

    > Note: This function is named GetPolicySegmentPorts in the Go SDK.

    public static class GetPolicySegmentPorts 
    {
        public static Task<GetPolicySegmentPortsResult> InvokeAsync(GetPolicySegmentPortsArgs args, InvokeOptions? opts = null)
        public static Output<GetPolicySegmentPortsResult> Invoke(GetPolicySegmentPortsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetPolicySegmentPortsResult> getPolicySegmentPorts(GetPolicySegmentPortsArgs args, InvokeOptions options)
    public static Output<GetPolicySegmentPortsResult> getPolicySegmentPorts(GetPolicySegmentPortsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: nsxt:index/getPolicySegmentPorts:getPolicySegmentPorts
      arguments:
        # arguments dictionary
    data "nsxt_getpolicysegmentports" "name" {
        # arguments
    }

    The following arguments are supported:

    Context GetPolicySegmentPortsContext
    The context which the object belongs to
    DisplayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    Id string
    Unique identifier of the segment port.
    SegmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    VifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    Context GetPolicySegmentPortsContext
    The context which the object belongs to
    DisplayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    Id string
    Unique identifier of the segment port.
    SegmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    VifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    context object
    The context which the object belongs to
    display_name string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id string
    Unique identifier of the segment port.
    segment_path string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vif_id string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    context GetPolicySegmentPortsContext
    The context which the object belongs to
    displayName String

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id String
    Unique identifier of the segment port.
    segmentPath String
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId String
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    context GetPolicySegmentPortsContext
    The context which the object belongs to
    displayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id string
    Unique identifier of the segment port.
    segmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    context GetPolicySegmentPortsContext
    The context which the object belongs to
    display_name str

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id str
    Unique identifier of the segment port.
    segment_path str
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vif_id str
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    context Property Map
    The context which the object belongs to
    displayName String

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id String
    Unique identifier of the segment port.
    segmentPath String
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId String
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.

    getPolicySegmentPorts Result

    The following output properties are available:

    Id string
    Unique identifier of the segment port.
    Items List<GetPolicySegmentPortsItem>
    List of segment ports matching the filter criteria. Each item contains:
    Context GetPolicySegmentPortsContext
    DisplayName string
    Display name of the segment port.
    SegmentPath string
    Parent segment path of the segment port.
    VifId string
    VIF attachment ID of the segment port (if attached).
    Id string
    Unique identifier of the segment port.
    Items []GetPolicySegmentPortsItem
    List of segment ports matching the filter criteria. Each item contains:
    Context GetPolicySegmentPortsContext
    DisplayName string
    Display name of the segment port.
    SegmentPath string
    Parent segment path of the segment port.
    VifId string
    VIF attachment ID of the segment port (if attached).
    id string
    Unique identifier of the segment port.
    items list(object)
    List of segment ports matching the filter criteria. Each item contains:
    context object
    display_name string
    Display name of the segment port.
    segment_path string
    Parent segment path of the segment port.
    vif_id string
    VIF attachment ID of the segment port (if attached).
    id String
    Unique identifier of the segment port.
    items List<GetPolicySegmentPortsItem>
    List of segment ports matching the filter criteria. Each item contains:
    context GetPolicySegmentPortsContext
    displayName String
    Display name of the segment port.
    segmentPath String
    Parent segment path of the segment port.
    vifId String
    VIF attachment ID of the segment port (if attached).
    id string
    Unique identifier of the segment port.
    items GetPolicySegmentPortsItem[]
    List of segment ports matching the filter criteria. Each item contains:
    context GetPolicySegmentPortsContext
    displayName string
    Display name of the segment port.
    segmentPath string
    Parent segment path of the segment port.
    vifId string
    VIF attachment ID of the segment port (if attached).
    id str
    Unique identifier of the segment port.
    items Sequence[GetPolicySegmentPortsItem]
    List of segment ports matching the filter criteria. Each item contains:
    context GetPolicySegmentPortsContext
    display_name str
    Display name of the segment port.
    segment_path str
    Parent segment path of the segment port.
    vif_id str
    VIF attachment ID of the segment port (if attached).
    id String
    Unique identifier of the segment port.
    items List<Property Map>
    List of segment ports matching the filter criteria. Each item contains:
    context Property Map
    displayName String
    Display name of the segment port.
    segmentPath String
    Parent segment path of the segment port.
    vifId String
    VIF attachment ID of the segment port (if attached).

    Supporting Types

    GetPolicySegmentPortsContext

    FromGlobal bool
    Search among global resource
    ProjectId string
    The ID of the project which the object belongs to
    FromGlobal bool
    Search among global resource
    ProjectId string
    The ID of the project which the object belongs to
    from_global bool
    Search among global resource
    project_id string
    The ID of the project which the object belongs to
    fromGlobal Boolean
    Search among global resource
    projectId String
    The ID of the project which the object belongs to
    fromGlobal boolean
    Search among global resource
    projectId string
    The ID of the project which the object belongs to
    from_global bool
    Search among global resource
    project_id str
    The ID of the project which the object belongs to
    fromGlobal Boolean
    Search among global resource
    projectId String
    The ID of the project which the object belongs to

    GetPolicySegmentPortsItem

    Description string
    Description of the segment port.
    DisplayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    Id string
    Unique identifier of the segment port.
    Path string
    Policy path of the segment port.
    SegmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    VifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    Description string
    Description of the segment port.
    DisplayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    Id string
    Unique identifier of the segment port.
    Path string
    Policy path of the segment port.
    SegmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    VifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    description string
    Description of the segment port.
    display_name string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id string
    Unique identifier of the segment port.
    path string
    Policy path of the segment port.
    segment_path string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vif_id string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    description String
    Description of the segment port.
    displayName String

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id String
    Unique identifier of the segment port.
    path String
    Policy path of the segment port.
    segmentPath String
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId String
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    description string
    Description of the segment port.
    displayName string

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id string
    Unique identifier of the segment port.
    path string
    Policy path of the segment port.
    segmentPath string
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId string
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    description str
    Description of the segment port.
    display_name str

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id str
    Unique identifier of the segment port.
    path str
    Policy path of the segment port.
    segment_path str
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vif_id str
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.
    description String
    Description of the segment port.
    displayName String

    Display name to filter segment ports. When used with vif_id, filters the VIF results by display name. When used with segment_path, filters the segment's ports by display name. When used alone, searches all segment ports by display name.

    NOTE: At least one of vif_id, segment_path, or display_name must be specified.

    id String
    Unique identifier of the segment port.
    path String
    Policy path of the segment port.
    segmentPath String
    Segment path to filter segment ports. Can be combined with vif_id or display_name.
    vifId String
    Segment Port attachment ID to filter segment ports. This takes priority over other filters.

    Package Details

    Repository
    nsxt vmware/terraform-provider-nsxt
    License
    Notes
    This Pulumi package is based on the nsxt Terraform Provider.
    Viewing docs for nsxt 3.12.0
    published on Monday, May 18, 2026 by vmware

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial