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

tencentcloud.getSubnet

Explore with Pulumi AI

tencentcloud 1.81.183 published on Wednesday, Apr 16, 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",
});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

subnet = tencentcloud.get_subnet(subnet_id="subnet-ezgfompo",
    vpc_id="vpc-ha5l97e3")
Copy
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
	})
}
Copy
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",
    });

});
Copy
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());

    }
}
Copy
variables:
  subnet:
    fn::invoke:
      function: tencentcloud:getSubnet
      arguments:
        subnetId: subnet-ezgfompo
        vpcId: vpc-ha5l97e3
Copy

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",
});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

subnet = tencentcloud.get_subnet(cdc_id="cluster-lchwgxhs",
    subnet_id="subnet-ezgfompo",
    vpc_id="vpc-ha5l97e3")
Copy
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
	})
}
Copy
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",
    });

});
Copy
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());

    }
}
Copy
variables:
  subnet:
    fn::invoke:
      function: tencentcloud:getSubnet
      arguments:
        cdcId: cluster-lchwgxhs
        subnetId: subnet-ezgfompo
        vpcId: vpc-ha5l97e3
Copy

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>
Copy
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]
Copy
func LookupSubnet(ctx *Context, args *LookupSubnetArgs, opts ...InvokeOption) (*LookupSubnetResult, error)
func LookupSubnetOutput(ctx *Context, args *LookupSubnetOutputArgs, opts ...InvokeOption) LookupSubnetResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
public static Output<GetSubnetResult> getSubnet(GetSubnetArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: tencentcloud:index/getSubnet:getSubnet
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

SubnetId This property is required. string
The ID of the Subnet.
VpcId This property is required. string
The VPC ID.
CdcId string
ID of CDC instance.
Id string
SubnetId This property is required. string
The ID of the Subnet.
VpcId This property is required. string
The VPC ID.
CdcId string
ID of CDC instance.
Id string
subnetId This property is required. String
The ID of the Subnet.
vpcId This property is required. String
The VPC ID.
cdcId String
ID of CDC instance.
id String
subnetId This property is required. string
The ID of the Subnet.
vpcId This property is required. string
The VPC ID.
cdcId string
ID of CDC instance.
id string
subnet_id This property is required. str
The ID of the Subnet.
vpc_id This property is required. str
The VPC ID.
cdc_id str
ID of CDC instance.
id str
subnetId This property is required. String
The ID of the Subnet.
vpcId This property is required. 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 1.81.183 published on Wednesday, Apr 16, 2025 by tencentcloudstack