tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack
tencentcloud.getVpcSubnets
Explore with Pulumi AI
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack
Use this data source to query vpc subnets information.
Example Usage
Create subnet resource
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const config = new pulumi.Config();
const availabilityZone = config.get("availabilityZone") || "ap-guangzhou-3";
const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
const subnet = new tencentcloud.Subnet("subnet", {
availabilityZone: availabilityZone,
vpcId: vpc.vpcId,
cidrBlock: "10.0.20.0/28",
isMulticast: false,
tags: {
test: "test",
},
});
const subnetCDC = new tencentcloud.Subnet("subnetCDC", {
vpcId: vpc.vpcId,
cidrBlock: "10.0.0.0/16",
cdcId: "cluster-lchwgxhs",
availabilityZone: data.tencentcloud_availability_zones.zones.zones[0].name,
isMulticast: false,
});
import pulumi
import pulumi_tencentcloud as tencentcloud
config = pulumi.Config()
availability_zone = config.get("availabilityZone")
if availability_zone is None:
availability_zone = "ap-guangzhou-3"
vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
subnet = tencentcloud.Subnet("subnet",
availability_zone=availability_zone,
vpc_id=vpc.vpc_id,
cidr_block="10.0.20.0/28",
is_multicast=False,
tags={
"test": "test",
})
subnet_cdc = tencentcloud.Subnet("subnetCDC",
vpc_id=vpc.vpc_id,
cidr_block="10.0.0.0/16",
cdc_id="cluster-lchwgxhs",
availability_zone=data["tencentcloud_availability_zones"]["zones"]["zones"][0]["name"],
is_multicast=False)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
availabilityZone := "ap-guangzhou-3"
if param := cfg.Get("availabilityZone"); param != "" {
availabilityZone = param
}
vpc, err := tencentcloud.NewVpc(ctx, "vpc", &tencentcloud.VpcArgs{
CidrBlock: pulumi.String("10.0.0.0/16"),
})
if err != nil {
return err
}
_, err = tencentcloud.NewSubnet(ctx, "subnet", &tencentcloud.SubnetArgs{
AvailabilityZone: pulumi.String(availabilityZone),
VpcId: vpc.VpcId,
CidrBlock: pulumi.String("10.0.20.0/28"),
IsMulticast: pulumi.Bool(false),
Tags: pulumi.StringMap{
"test": pulumi.String("test"),
},
})
if err != nil {
return err
}
_, err = tencentcloud.NewSubnet(ctx, "subnetCDC", &tencentcloud.SubnetArgs{
VpcId: vpc.VpcId,
CidrBlock: pulumi.String("10.0.0.0/16"),
CdcId: pulumi.String("cluster-lchwgxhs"),
AvailabilityZone: pulumi.Any(data.Tencentcloud_availability_zones.Zones.Zones[0].Name),
IsMulticast: pulumi.Bool(false),
})
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 config = new Config();
var availabilityZone = config.Get("availabilityZone") ?? "ap-guangzhou-3";
var vpc = new Tencentcloud.Vpc("vpc", new()
{
CidrBlock = "10.0.0.0/16",
});
var subnet = new Tencentcloud.Subnet("subnet", new()
{
AvailabilityZone = availabilityZone,
VpcId = vpc.VpcId,
CidrBlock = "10.0.20.0/28",
IsMulticast = false,
Tags =
{
{ "test", "test" },
},
});
var subnetCDC = new Tencentcloud.Subnet("subnetCDC", new()
{
VpcId = vpc.VpcId,
CidrBlock = "10.0.0.0/16",
CdcId = "cluster-lchwgxhs",
AvailabilityZone = data.Tencentcloud_availability_zones.Zones.Zones[0].Name,
IsMulticast = false,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.Vpc;
import com.pulumi.tencentcloud.VpcArgs;
import com.pulumi.tencentcloud.Subnet;
import com.pulumi.tencentcloud.SubnetArgs;
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 config = ctx.config();
final var availabilityZone = config.get("availabilityZone").orElse("ap-guangzhou-3");
var vpc = new Vpc("vpc", VpcArgs.builder()
.cidrBlock("10.0.0.0/16")
.build());
var subnet = new Subnet("subnet", SubnetArgs.builder()
.availabilityZone(availabilityZone)
.vpcId(vpc.vpcId())
.cidrBlock("10.0.20.0/28")
.isMulticast(false)
.tags(Map.of("test", "test"))
.build());
var subnetCDC = new Subnet("subnetCDC", SubnetArgs.builder()
.vpcId(vpc.vpcId())
.cidrBlock("10.0.0.0/16")
.cdcId("cluster-lchwgxhs")
.availabilityZone(data.tencentcloud_availability_zones().zones().zones()[0].name())
.isMulticast(false)
.build());
}
}
configuration:
availabilityZone:
type: string
default: ap-guangzhou-3
resources:
vpc:
type: tencentcloud:Vpc
properties:
cidrBlock: 10.0.0.0/16
subnet:
type: tencentcloud:Subnet
properties:
availabilityZone: ${availabilityZone}
vpcId: ${vpc.vpcId}
cidrBlock: 10.0.20.0/28
isMulticast: false
tags:
test: test
subnetCDC:
type: tencentcloud:Subnet
properties:
vpcId: ${vpc.vpcId}
cidrBlock: 10.0.0.0/16
cdcId: cluster-lchwgxhs
availabilityZone: ${data.tencentcloud_availability_zones.zones.zones[0].name}
isMulticast: false
Query all subnets
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const subnets = tencentcloud.getVpcSubnets({});
import pulumi
import pulumi_tencentcloud as tencentcloud
subnets = tencentcloud.get_vpc_subnets()
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.GetVpcSubnets(ctx, &tencentcloud.GetVpcSubnetsArgs{}, 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 subnets = Tencentcloud.GetVpcSubnets.Invoke();
});
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.GetVpcSubnetsArgs;
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 subnets = TencentcloudFunctions.getVpcSubnets();
}
}
variables:
subnets:
fn::invoke:
function: tencentcloud:getVpcSubnets
arguments: {}
Using getVpcSubnets
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 getVpcSubnets(args: GetVpcSubnetsArgs, opts?: InvokeOptions): Promise<GetVpcSubnetsResult>
function getVpcSubnetsOutput(args: GetVpcSubnetsOutputArgs, opts?: InvokeOptions): Output<GetVpcSubnetsResult>
def get_vpc_subnets(availability_zone: Optional[str] = None,
cdc_id: Optional[str] = None,
cidr_block: Optional[str] = None,
id: Optional[str] = None,
is_default: Optional[bool] = None,
is_remote_vpc_snat: Optional[bool] = None,
name: Optional[str] = None,
result_output_file: Optional[str] = None,
subnet_id: Optional[str] = None,
tag_key: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
vpc_id: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetVpcSubnetsResult
def get_vpc_subnets_output(availability_zone: Optional[pulumi.Input[str]] = None,
cdc_id: Optional[pulumi.Input[str]] = None,
cidr_block: Optional[pulumi.Input[str]] = None,
id: Optional[pulumi.Input[str]] = None,
is_default: Optional[pulumi.Input[bool]] = None,
is_remote_vpc_snat: Optional[pulumi.Input[bool]] = None,
name: Optional[pulumi.Input[str]] = None,
result_output_file: Optional[pulumi.Input[str]] = None,
subnet_id: Optional[pulumi.Input[str]] = None,
tag_key: Optional[pulumi.Input[str]] = None,
tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
vpc_id: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetVpcSubnetsResult]
func GetVpcSubnets(ctx *Context, args *GetVpcSubnetsArgs, opts ...InvokeOption) (*GetVpcSubnetsResult, error)
func GetVpcSubnetsOutput(ctx *Context, args *GetVpcSubnetsOutputArgs, opts ...InvokeOption) GetVpcSubnetsResultOutput
> Note: This function is named GetVpcSubnets
in the Go SDK.
public static class GetVpcSubnets
{
public static Task<GetVpcSubnetsResult> InvokeAsync(GetVpcSubnetsArgs args, InvokeOptions? opts = null)
public static Output<GetVpcSubnetsResult> Invoke(GetVpcSubnetsInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetVpcSubnetsResult> getVpcSubnets(GetVpcSubnetsArgs args, InvokeOptions options)
public static Output<GetVpcSubnetsResult> getVpcSubnets(GetVpcSubnetsArgs args, InvokeOptions options)
fn::invoke:
function: tencentcloud:index/getVpcSubnets:getVpcSubnets
arguments:
# arguments dictionary
The following arguments are supported:
- Availability
Zone string - Zone of the subnet to be queried.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - Filter subnet with this CIDR.
- Id string
- Is
Default bool - Filter default or no default subnets.
- Is
Remote boolVpc Snat - Filter the VPC SNAT address pool subnet.
- Name string
- Name of the subnet to be queried.
- Result
Output stringFile - Used to save results.
- Subnet
Id string - ID of the subnet to be queried.
- Tag
Key string - Filter if subnet has this tag.
- Dictionary<string, string>
- Tags of the subnet to be queried.
- Vpc
Id string - ID of the VPC to be queried.
- Availability
Zone string - Zone of the subnet to be queried.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - Filter subnet with this CIDR.
- Id string
- Is
Default bool - Filter default or no default subnets.
- Is
Remote boolVpc Snat - Filter the VPC SNAT address pool subnet.
- Name string
- Name of the subnet to be queried.
- Result
Output stringFile - Used to save results.
- Subnet
Id string - ID of the subnet to be queried.
- Tag
Key string - Filter if subnet has this tag.
- map[string]string
- Tags of the subnet to be queried.
- Vpc
Id string - ID of the VPC to be queried.
- availability
Zone String - Zone of the subnet to be queried.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - Filter subnet with this CIDR.
- id String
- is
Default Boolean - Filter default or no default subnets.
- is
Remote BooleanVpc Snat - Filter the VPC SNAT address pool subnet.
- name String
- Name of the subnet to be queried.
- result
Output StringFile - Used to save results.
- subnet
Id String - ID of the subnet to be queried.
- tag
Key String - Filter if subnet has this tag.
- Map<String,String>
- Tags of the subnet to be queried.
- vpc
Id String - ID of the VPC to be queried.
- availability
Zone string - Zone of the subnet to be queried.
- cdc
Id string - ID of CDC instance.
- cidr
Block string - Filter subnet with this CIDR.
- id string
- is
Default boolean - Filter default or no default subnets.
- is
Remote booleanVpc Snat - Filter the VPC SNAT address pool subnet.
- name string
- Name of the subnet to be queried.
- result
Output stringFile - Used to save results.
- subnet
Id string - ID of the subnet to be queried.
- tag
Key string - Filter if subnet has this tag.
- {[key: string]: string}
- Tags of the subnet to be queried.
- vpc
Id string - ID of the VPC to be queried.
- availability_
zone str - Zone of the subnet to be queried.
- cdc_
id str - ID of CDC instance.
- cidr_
block str - Filter subnet with this CIDR.
- id str
- is_
default bool - Filter default or no default subnets.
- is_
remote_ boolvpc_ snat - Filter the VPC SNAT address pool subnet.
- name str
- Name of the subnet to be queried.
- result_
output_ strfile - Used to save results.
- subnet_
id str - ID of the subnet to be queried.
- tag_
key str - Filter if subnet has this tag.
- Mapping[str, str]
- Tags of the subnet to be queried.
- vpc_
id str - ID of the VPC to be queried.
- availability
Zone String - Zone of the subnet to be queried.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - Filter subnet with this CIDR.
- id String
- is
Default Boolean - Filter default or no default subnets.
- is
Remote BooleanVpc Snat - Filter the VPC SNAT address pool subnet.
- name String
- Name of the subnet to be queried.
- result
Output StringFile - Used to save results.
- subnet
Id String - ID of the subnet to be queried.
- tag
Key String - Filter if subnet has this tag.
- Map<String>
- Tags of the subnet to be queried.
- vpc
Id String - ID of the VPC to be queried.
getVpcSubnets Result
The following output properties are available:
- Id string
- Instance
Lists List<GetVpc Subnets Instance List> - List of subnets.
- Availability
Zone string - The availability zone of the subnet.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - A network address block of the subnet.
- Is
Default bool - Indicates whether it is the default subnet of the VPC for this region.
- Is
Remote boolVpc Snat - Name string
- Name of the subnet.
- Result
Output stringFile - Subnet
Id string - ID of the subnet.
- Tag
Key string - Dictionary<string, string>
- Tags of the subnet resource.
- Vpc
Id string - ID of the VPC.
- Id string
- Instance
Lists []GetVpc Subnets Instance List - List of subnets.
- Availability
Zone string - The availability zone of the subnet.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - A network address block of the subnet.
- Is
Default bool - Indicates whether it is the default subnet of the VPC for this region.
- Is
Remote boolVpc Snat - Name string
- Name of the subnet.
- Result
Output stringFile - Subnet
Id string - ID of the subnet.
- Tag
Key string - map[string]string
- Tags of the subnet resource.
- Vpc
Id string - ID of the VPC.
- id String
- instance
Lists List<GetVpc Subnets Instance List> - List of subnets.
- availability
Zone String - The availability zone of the subnet.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - A network address block of the subnet.
- is
Default Boolean - Indicates whether it is the default subnet of the VPC for this region.
- is
Remote BooleanVpc Snat - name String
- Name of the subnet.
- result
Output StringFile - subnet
Id String - ID of the subnet.
- tag
Key String - Map<String,String>
- Tags of the subnet resource.
- vpc
Id String - ID of the VPC.
- id string
- instance
Lists GetVpc Subnets Instance List[] - List of subnets.
- availability
Zone string - The availability zone of the subnet.
- cdc
Id string - ID of CDC instance.
- cidr
Block string - A network address block of the subnet.
- is
Default boolean - Indicates whether it is the default subnet of the VPC for this region.
- is
Remote booleanVpc Snat - name string
- Name of the subnet.
- result
Output stringFile - subnet
Id string - ID of the subnet.
- tag
Key string - {[key: string]: string}
- Tags of the subnet resource.
- vpc
Id string - ID of the VPC.
- id str
- instance_
lists Sequence[GetVpc Subnets Instance List] - List of subnets.
- availability_
zone str - The availability zone of the subnet.
- cdc_
id str - ID of CDC instance.
- cidr_
block str - A network address block of the subnet.
- is_
default bool - Indicates whether it is the default subnet of the VPC for this region.
- is_
remote_ boolvpc_ snat - name str
- Name of the subnet.
- result_
output_ strfile - subnet_
id str - ID of the subnet.
- tag_
key str - Mapping[str, str]
- Tags of the subnet resource.
- vpc_
id str - ID of the VPC.
- id String
- instance
Lists List<Property Map> - List of subnets.
- availability
Zone String - The availability zone of the subnet.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - A network address block of the subnet.
- is
Default Boolean - Indicates whether it is the default subnet of the VPC for this region.
- is
Remote BooleanVpc Snat - name String
- Name of the subnet.
- result
Output StringFile - subnet
Id String - ID of the subnet.
- tag
Key String - Map<String>
- Tags of the subnet resource.
- vpc
Id String - ID of the VPC.
Supporting Types
GetVpcSubnetsInstanceList
- Availability
Zone string - Zone of the subnet to be queried.
- Available
Ip doubleCount - The number of available IPs.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - Filter subnet with this CIDR.
- Create
Time string - Creation time of the subnet resource.
- Is
Default bool - Filter default or no default subnets.
- Is
Multicast bool - Indicates whether multicast is enabled.
- Name string
- Name of the subnet to be queried.
- Route
Table stringId - ID of the routing table.
- Subnet
Id string - ID of the subnet to be queried.
- Dictionary<string, string>
- Tags of the subnet to be queried.
- Vpc
Id string - ID of the VPC to be queried.
- Availability
Zone string - Zone of the subnet to be queried.
- Available
Ip float64Count - The number of available IPs.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - Filter subnet with this CIDR.
- Create
Time string - Creation time of the subnet resource.
- Is
Default bool - Filter default or no default subnets.
- Is
Multicast bool - Indicates whether multicast is enabled.
- Name string
- Name of the subnet to be queried.
- Route
Table stringId - ID of the routing table.
- Subnet
Id string - ID of the subnet to be queried.
- map[string]string
- Tags of the subnet to be queried.
- Vpc
Id string - ID of the VPC to be queried.
- availability
Zone String - Zone of the subnet to be queried.
- available
Ip DoubleCount - The number of available IPs.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - Filter subnet with this CIDR.
- create
Time String - Creation time of the subnet resource.
- is
Default Boolean - Filter default or no default subnets.
- is
Multicast Boolean - Indicates whether multicast is enabled.
- name String
- Name of the subnet to be queried.
- route
Table StringId - ID of the routing table.
- subnet
Id String - ID of the subnet to be queried.
- Map<String,String>
- Tags of the subnet to be queried.
- vpc
Id String - ID of the VPC to be queried.
- availability
Zone string - Zone of the subnet to be queried.
- available
Ip numberCount - The number of available IPs.
- cdc
Id string - ID of CDC instance.
- cidr
Block string - Filter subnet with this CIDR.
- create
Time string - Creation time of the subnet resource.
- is
Default boolean - Filter default or no default subnets.
- is
Multicast boolean - Indicates whether multicast is enabled.
- name string
- Name of the subnet to be queried.
- route
Table stringId - ID of the routing table.
- subnet
Id string - ID of the subnet to be queried.
- {[key: string]: string}
- Tags of the subnet to be queried.
- vpc
Id string - ID of the VPC to be queried.
- availability_
zone str - Zone of the subnet to be queried.
- available_
ip_ floatcount - The number of available IPs.
- cdc_
id str - ID of CDC instance.
- cidr_
block str - Filter subnet with this CIDR.
- create_
time str - Creation time of the subnet resource.
- is_
default bool - Filter default or no default subnets.
- is_
multicast bool - Indicates whether multicast is enabled.
- name str
- Name of the subnet to be queried.
- route_
table_ strid - ID of the routing table.
- subnet_
id str - ID of the subnet to be queried.
- Mapping[str, str]
- Tags of the subnet to be queried.
- vpc_
id str - ID of the VPC to be queried.
- availability
Zone String - Zone of the subnet to be queried.
- available
Ip NumberCount - The number of available IPs.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - Filter subnet with this CIDR.
- create
Time String - Creation time of the subnet resource.
- is
Default Boolean - Filter default or no default subnets.
- is
Multicast Boolean - Indicates whether multicast is enabled.
- name String
- Name of the subnet to be queried.
- route
Table StringId - ID of the routing table.
- subnet
Id String - ID of the subnet to be queried.
- Map<String>
- Tags of the subnet to be queried.
- vpc
Id String - ID of the VPC to be queried.
Package Details
- Repository
- tencentcloud tencentcloudstack/terraform-provider-tencentcloud
- License
- Notes
- This Pulumi package is based on the
tencentcloud
Terraform Provider.
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack