1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. getSubnet
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.getSubnet

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Provides details about a specific VPC subnet.

    This resource can prove useful when a module accepts a subnet id as an input variable and needs to, for example, determine the id of the VPC that the subnet belongs to.

    NOTE: It has been deprecated and replaced by tencentcloud_vpc_subnets.

    Example Usage

    Query method 1

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const subnet = tencentcloud.getSubnet({
        subnetId: "subnet-ezgfompo",
        vpcId: "vpc-ha5l97e3",
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    subnet = tencentcloud.get_subnet(subnet_id="subnet-ezgfompo",
        vpc_id="vpc-ha5l97e3")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := tencentcloud.LookupSubnet(ctx, &tencentcloud.LookupSubnetArgs{
    			SubnetId: "subnet-ezgfompo",
    			VpcId:    "vpc-ha5l97e3",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var subnet = Tencentcloud.GetSubnet.Invoke(new()
        {
            SubnetId = "subnet-ezgfompo",
            VpcId = "vpc-ha5l97e3",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.TencentcloudFunctions;
    import com.pulumi.tencentcloud.inputs.GetSubnetArgs;
    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 subnet = TencentcloudFunctions.getSubnet(GetSubnetArgs.builder()
                .subnetId("subnet-ezgfompo")
                .vpcId("vpc-ha5l97e3")
                .build());
    
        }
    }
    
    variables:
      subnet:
        fn::invoke:
          function: tencentcloud:getSubnet
          arguments:
            subnetId: subnet-ezgfompo
            vpcId: vpc-ha5l97e3
    

    Query method 2

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const subnet = tencentcloud.getSubnet({
        cdcId: "cluster-lchwgxhs",
        subnetId: "subnet-ezgfompo",
        vpcId: "vpc-ha5l97e3",
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    subnet = tencentcloud.get_subnet(cdc_id="cluster-lchwgxhs",
        subnet_id="subnet-ezgfompo",
        vpc_id="vpc-ha5l97e3")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := tencentcloud.LookupSubnet(ctx, &tencentcloud.LookupSubnetArgs{
    			CdcId:    pulumi.StringRef("cluster-lchwgxhs"),
    			SubnetId: "subnet-ezgfompo",
    			VpcId:    "vpc-ha5l97e3",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var subnet = Tencentcloud.GetSubnet.Invoke(new()
        {
            CdcId = "cluster-lchwgxhs",
            SubnetId = "subnet-ezgfompo",
            VpcId = "vpc-ha5l97e3",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.TencentcloudFunctions;
    import com.pulumi.tencentcloud.inputs.GetSubnetArgs;
    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 subnet = TencentcloudFunctions.getSubnet(GetSubnetArgs.builder()
                .cdcId("cluster-lchwgxhs")
                .subnetId("subnet-ezgfompo")
                .vpcId("vpc-ha5l97e3")
                .build());
    
        }
    }
    
    variables:
      subnet:
        fn::invoke:
          function: tencentcloud:getSubnet
          arguments:
            cdcId: cluster-lchwgxhs
            subnetId: subnet-ezgfompo
            vpcId: vpc-ha5l97e3
    

    Using getSubnet

    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 getSubnet(args: GetSubnetArgs, opts?: InvokeOptions): Promise<GetSubnetResult>
    function getSubnetOutput(args: GetSubnetOutputArgs, opts?: InvokeOptions): Output<GetSubnetResult>
    def get_subnet(cdc_id: Optional[str] = None,
                   id: Optional[str] = None,
                   subnet_id: Optional[str] = None,
                   vpc_id: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetSubnetResult
    def get_subnet_output(cdc_id: Optional[pulumi.Input[str]] = None,
                   id: Optional[pulumi.Input[str]] = None,
                   subnet_id: Optional[pulumi.Input[str]] = None,
                   vpc_id: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetSubnetResult]
    func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
    func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput

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

    public static class GetSubnet 
    {
        public static Task<GetSubnetResult> InvokeAsync(GetSubnetArgs args, InvokeOptions? opts = null)
        public static Output<GetSubnetResult> Invoke(GetSubnetInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
    public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
    
    fn::invoke:
      function: tencentcloud:index/getSubnet:getSubnet
      arguments:
        # arguments dictionary

    The following arguments are supported:

    SubnetId string
    The ID of the Subnet.
    VpcId string
    The VPC ID.
    CdcId string
    ID of CDC instance.
    Id string
    SubnetId string
    The ID of the Subnet.
    VpcId string
    The VPC ID.
    CdcId string
    ID of CDC instance.
    Id string
    subnetId String
    The ID of the Subnet.
    vpcId String
    The VPC ID.
    cdcId String
    ID of CDC instance.
    id String
    subnetId string
    The ID of the Subnet.
    vpcId string
    The VPC ID.
    cdcId string
    ID of CDC instance.
    id string
    subnet_id str
    The ID of the Subnet.
    vpc_id str
    The VPC ID.
    cdc_id str
    ID of CDC instance.
    id str
    subnetId String
    The ID of the Subnet.
    vpcId String
    The VPC ID.
    cdcId String
    ID of CDC instance.
    id String

    getSubnet Result

    The following output properties are available:

    AvailabilityZone string
    The AZ for the subnet.
    CdcId string
    CidrBlock string
    The CIDR block of the Subnet.
    Id string
    Name string
    The name for the Subnet.
    RouteTableId string
    The Route Table ID.
    SubnetId string
    VpcId string
    AvailabilityZone string
    The AZ for the subnet.
    CdcId string
    CidrBlock string
    The CIDR block of the Subnet.
    Id string
    Name string
    The name for the Subnet.
    RouteTableId string
    The Route Table ID.
    SubnetId string
    VpcId string
    availabilityZone String
    The AZ for the subnet.
    cdcId String
    cidrBlock String
    The CIDR block of the Subnet.
    id String
    name String
    The name for the Subnet.
    routeTableId String
    The Route Table ID.
    subnetId String
    vpcId String
    availabilityZone string
    The AZ for the subnet.
    cdcId string
    cidrBlock string
    The CIDR block of the Subnet.
    id string
    name string
    The name for the Subnet.
    routeTableId string
    The Route Table ID.
    subnetId string
    vpcId string
    availability_zone str
    The AZ for the subnet.
    cdc_id str
    cidr_block str
    The CIDR block of the Subnet.
    id str
    name str
    The name for the Subnet.
    route_table_id str
    The Route Table ID.
    subnet_id str
    vpc_id str
    availabilityZone String
    The AZ for the subnet.
    cdcId String
    cidrBlock String
    The CIDR block of the Subnet.
    id String
    name String
    The name for the Subnet.
    routeTableId String
    The Route Table ID.
    subnetId String
    vpcId String

    Package Details

    Repository
    tencentcloud tencentcloudstack/terraform-provider-tencentcloud
    License
    Notes
    This Pulumi package is based on the tencentcloud Terraform Provider.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack