nsxt 3.10.0 published on Wednesday, Sep 10, 2025 by vmware
nsxt.getVpcSubnetPort
Start a Neo task
Explain and create a nsxt.getVpcSubnetPort resource
This data source provides information about Subnet Port configured under VPC on NSX.
This data source is applicable to NSX Policy Manager.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as nsxt from "@pulumi/nsxt";
const demoproj = nsxt.getPolicyProject({
displayName: "demoproj",
});
const demovpc = demoproj.then(demoproj => nsxt.getVpc({
context: {
projectId: demoproj.id,
},
displayName: "vpc1",
}));
const testVpcSubnet = Promise.all([demoproj, demovpc]).then(([demoproj, demovpc]) => nsxt.getVpcSubnet({
context: {
projectId: demoproj.id,
vpcId: demovpc.id,
},
displayName: "subnet1",
}));
const testVpcSubnetPort = testVpcSubnet.then(testVpcSubnet => nsxt.getVpcSubnetPort({
subnetPath: testVpcSubnet.path,
vmId: data.vpshere_virtual_machine.vm1.id,
}));
import pulumi
import pulumi_nsxt as nsxt
demoproj = nsxt.get_policy_project(display_name="demoproj")
demovpc = nsxt.get_vpc(context={
"project_id": demoproj.id,
},
display_name="vpc1")
test_vpc_subnet = nsxt.get_vpc_subnet(context={
"project_id": demoproj.id,
"vpc_id": demovpc.id,
},
display_name="subnet1")
test_vpc_subnet_port = nsxt.get_vpc_subnet_port(subnet_path=test_vpc_subnet.path,
vm_id=data["vpshere_virtual_machine"]["vm1"]["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 {
demoproj, err := nsxt.LookupPolicyProject(ctx, &nsxt.LookupPolicyProjectArgs{
DisplayName: pulumi.StringRef("demoproj"),
}, nil)
if err != nil {
return err
}
demovpc, err := nsxt.LookupVpc(ctx, &nsxt.LookupVpcArgs{
Context: nsxt.GetVpcContext{
ProjectId: demoproj.Id,
},
DisplayName: pulumi.StringRef("vpc1"),
}, nil)
if err != nil {
return err
}
testVpcSubnet, err := nsxt.LookupVpcSubnet(ctx, &nsxt.LookupVpcSubnetArgs{
Context: nsxt.GetVpcSubnetContext{
ProjectId: demoproj.Id,
VpcId: demovpc.Id,
},
DisplayName: pulumi.StringRef("subnet1"),
}, nil)
if err != nil {
return err
}
_, err = nsxt.GetVpcSubnetPort(ctx, &nsxt.GetVpcSubnetPortArgs{
SubnetPath: testVpcSubnet.Path,
VmId: data.Vpshere_virtual_machine.Vm1.Id,
}, 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 demovpc = Nsxt.GetVpc.Invoke(new()
{
Context = new Nsxt.Inputs.GetVpcContextInputArgs
{
ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
},
DisplayName = "vpc1",
});
var testVpcSubnet = Nsxt.GetVpcSubnet.Invoke(new()
{
Context = new Nsxt.Inputs.GetVpcSubnetContextInputArgs
{
ProjectId = demoproj.Apply(getPolicyProjectResult => getPolicyProjectResult.Id),
VpcId = demovpc.Apply(getVpcResult => getVpcResult.Id),
},
DisplayName = "subnet1",
});
var testVpcSubnetPort = Nsxt.GetVpcSubnetPort.Invoke(new()
{
SubnetPath = testVpcSubnet.Apply(getVpcSubnetResult => getVpcSubnetResult.Path),
VmId = data.Vpshere_virtual_machine.Vm1.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.GetPolicyProjectArgs;
import com.pulumi.nsxt.inputs.GetVpcArgs;
import com.pulumi.nsxt.inputs.GetVpcContextArgs;
import com.pulumi.nsxt.inputs.GetVpcSubnetArgs;
import com.pulumi.nsxt.inputs.GetVpcSubnetContextArgs;
import com.pulumi.nsxt.inputs.GetVpcSubnetPortArgs;
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 demovpc = NsxtFunctions.getVpc(GetVpcArgs.builder()
.context(GetVpcContextArgs.builder()
.projectId(demoproj.applyValue(getPolicyProjectResult -> getPolicyProjectResult.id()))
.build())
.displayName("vpc1")
.build());
final var testVpcSubnet = NsxtFunctions.getVpcSubnet(GetVpcSubnetArgs.builder()
.context(GetVpcSubnetContextArgs.builder()
.projectId(demoproj.applyValue(getPolicyProjectResult -> getPolicyProjectResult.id()))
.vpcId(demovpc.applyValue(getVpcResult -> getVpcResult.id()))
.build())
.displayName("subnet1")
.build());
final var testVpcSubnetPort = NsxtFunctions.getVpcSubnetPort(GetVpcSubnetPortArgs.builder()
.subnetPath(testVpcSubnet.applyValue(getVpcSubnetResult -> getVpcSubnetResult.path()))
.vmId(data.vpshere_virtual_machine().vm1().id())
.build());
}
}
variables:
demoproj:
fn::invoke:
function: nsxt:getPolicyProject
arguments:
displayName: demoproj
demovpc:
fn::invoke:
function: nsxt:getVpc
arguments:
context:
projectId: ${demoproj.id}
displayName: vpc1
testVpcSubnet:
fn::invoke:
function: nsxt:getVpcSubnet
arguments:
context:
projectId: ${demoproj.id}
vpcId: ${demovpc.id}
displayName: subnet1
testVpcSubnetPort:
fn::invoke:
function: nsxt:getVpcSubnetPort
arguments:
subnetPath: ${testVpcSubnet.path}
vmId: ${data.vpshere_virtual_machine.vm1.id}
Using getVpcSubnetPort
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 getVpcSubnetPort(args: GetVpcSubnetPortArgs, opts?: InvokeOptions): Promise<GetVpcSubnetPortResult>
function getVpcSubnetPortOutput(args: GetVpcSubnetPortOutputArgs, opts?: InvokeOptions): Output<GetVpcSubnetPortResult>def get_vpc_subnet_port(description: Optional[str] = None,
display_name: Optional[str] = None,
id: Optional[str] = None,
subnet_path: Optional[str] = None,
vm_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetVpcSubnetPortResult
def get_vpc_subnet_port_output(description: Optional[pulumi.Input[str]] = None,
display_name: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
subnet_path: Optional[pulumi.Input[str]] = None,
vm_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVpcSubnetPortResult]func GetVpcSubnetPort(ctx *Context, args *GetVpcSubnetPortArgs, opts ...InvokeOption) (*GetVpcSubnetPortResult, error)
func GetVpcSubnetPortOutput(ctx *Context, args *GetVpcSubnetPortOutputArgs, opts ...InvokeOption) GetVpcSubnetPortResultOutput> Note: This function is named GetVpcSubnetPort in the Go SDK.
public static class GetVpcSubnetPort
{
public static Task<GetVpcSubnetPortResult> InvokeAsync(GetVpcSubnetPortArgs args, InvokeOptions? opts = null)
public static Output<GetVpcSubnetPortResult> Invoke(GetVpcSubnetPortInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetVpcSubnetPortResult> getVpcSubnetPort(GetVpcSubnetPortArgs args, InvokeOptions options)
public static Output<GetVpcSubnetPortResult> getVpcSubnetPort(GetVpcSubnetPortArgs args, InvokeOptions options)
fn::invoke:
function: nsxt:index/getVpcSubnetPort:getVpcSubnetPort
arguments:
# arguments dictionaryThe following arguments are supported:
- Subnet
Path string - Policy path of Subnet for the port.
- Vm
Id string - Policy path of VM connected to the port.
- Description string
- The description of the resource.
- Display
Name string - The Display Name of the resource.
- Id string
- Subnet
Path string - Policy path of Subnet for the port.
- Vm
Id string - Policy path of VM connected to the port.
- Description string
- The description of the resource.
- Display
Name string - The Display Name of the resource.
- Id string
- subnet
Path String - Policy path of Subnet for the port.
- vm
Id String - Policy path of VM connected to the port.
- description String
- The description of the resource.
- display
Name String - The Display Name of the resource.
- id String
- subnet
Path string - Policy path of Subnet for the port.
- vm
Id string - Policy path of VM connected to the port.
- description string
- The description of the resource.
- display
Name string - The Display Name of the resource.
- id string
- subnet_
path str - Policy path of Subnet for the port.
- vm_
id str - Policy path of VM connected to the port.
- description str
- The description of the resource.
- display_
name str - The Display Name of the resource.
- id str
- subnet
Path String - Policy path of Subnet for the port.
- vm
Id String - Policy path of VM connected to the port.
- description String
- The description of the resource.
- display
Name String - The Display Name of the resource.
- id String
getVpcSubnetPort Result
The following output properties are available:
- Description string
- The description of the resource.
- Display
Name string - The Display Name of the resource.
- Id string
- Path string
- The NSX path of the policy resource.
- Subnet
Path string - Vm
Id string
- Description string
- The description of the resource.
- Display
Name string - The Display Name of the resource.
- Id string
- Path string
- The NSX path of the policy resource.
- Subnet
Path string - Vm
Id string
- description String
- The description of the resource.
- display
Name String - The Display Name of the resource.
- id String
- path String
- The NSX path of the policy resource.
- subnet
Path String - vm
Id String
- description string
- The description of the resource.
- display
Name string - The Display Name of the resource.
- id string
- path string
- The NSX path of the policy resource.
- subnet
Path string - vm
Id string
- description str
- The description of the resource.
- display_
name str - The Display Name of the resource.
- id str
- path str
- The NSX path of the policy resource.
- subnet_
path str - vm_
id str
- description String
- The description of the resource.
- display
Name String - The Display Name of the resource.
- id String
- path String
- The NSX path of the policy resource.
- subnet
Path String - vm
Id String
Package Details
- Repository
- nsxt vmware/terraform-provider-nsxt
- License
- Notes
- This Pulumi package is based on the
nsxtTerraform Provider.
