tencentcloud.Subnet
Explore with Pulumi AI
Provide a resource to create a VPC subnet.
Example Usage
Create a normal VPC subnet
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const zones = tencentcloud.getAvailabilityZones({});
const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
const subnet = new tencentcloud.Subnet("subnet", {
vpcId: vpc.vpcId,
cidrBlock: "10.0.0.0/16",
availabilityZone: zones.then(zones => zones.zones?.[0]?.name),
isMulticast: false,
});
import pulumi
import pulumi_tencentcloud as tencentcloud
zones = tencentcloud.get_availability_zones()
vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
subnet = tencentcloud.Subnet("subnet",
vpc_id=vpc.vpc_id,
cidr_block="10.0.0.0/16",
availability_zone=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"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
zones, err := tencentcloud.GetAvailabilityZones(ctx, &tencentcloud.GetAvailabilityZonesArgs{}, nil)
if err != nil {
return err
}
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{
VpcId: vpc.VpcId,
CidrBlock: pulumi.String("10.0.0.0/16"),
AvailabilityZone: pulumi.String(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 zones = Tencentcloud.GetAvailabilityZones.Invoke();
var vpc = new Tencentcloud.Vpc("vpc", new()
{
CidrBlock = "10.0.0.0/16",
});
var subnet = new Tencentcloud.Subnet("subnet", new()
{
VpcId = vpc.VpcId,
CidrBlock = "10.0.0.0/16",
AvailabilityZone = zones.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.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.TencentcloudFunctions;
import com.pulumi.tencentcloud.inputs.GetAvailabilityZonesArgs;
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 zones = TencentcloudFunctions.getAvailabilityZones();
var vpc = new Vpc("vpc", VpcArgs.builder()
.cidrBlock("10.0.0.0/16")
.build());
var subnet = new Subnet("subnet", SubnetArgs.builder()
.vpcId(vpc.vpcId())
.cidrBlock("10.0.0.0/16")
.availabilityZone(zones.applyValue(getAvailabilityZonesResult -> getAvailabilityZonesResult.zones()[0].name()))
.isMulticast(false)
.build());
}
}
resources:
vpc:
type: tencentcloud:Vpc
properties:
cidrBlock: 10.0.0.0/16
subnet:
type: tencentcloud:Subnet
properties:
vpcId: ${vpc.vpcId}
cidrBlock: 10.0.0.0/16
availabilityZone: ${zones.zones[0].name}
isMulticast: false
variables:
zones:
fn::invoke:
function: tencentcloud:getAvailabilityZones
arguments: {}
Create a CDC instance VPC subnet
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
const zones = tencentcloud.getAvailabilityZones({});
const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
const subnet = new tencentcloud.Subnet("subnet", {
vpcId: vpc.vpcId,
cidrBlock: "10.0.0.0/16",
cdcId: "cluster-lchwgxhs",
availabilityZone: zones.then(zones => zones.zones?.[0]?.name),
isMulticast: false,
});
import pulumi
import pulumi_tencentcloud as tencentcloud
zones = tencentcloud.get_availability_zones()
vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
subnet = tencentcloud.Subnet("subnet",
vpc_id=vpc.vpc_id,
cidr_block="10.0.0.0/16",
cdc_id="cluster-lchwgxhs",
availability_zone=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"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
zones, err := tencentcloud.GetAvailabilityZones(ctx, &tencentcloud.GetAvailabilityZonesArgs{}, nil)
if err != nil {
return err
}
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{
VpcId: vpc.VpcId,
CidrBlock: pulumi.String("10.0.0.0/16"),
CdcId: pulumi.String("cluster-lchwgxhs"),
AvailabilityZone: pulumi.String(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 zones = Tencentcloud.GetAvailabilityZones.Invoke();
var vpc = new Tencentcloud.Vpc("vpc", new()
{
CidrBlock = "10.0.0.0/16",
});
var subnet = new Tencentcloud.Subnet("subnet", new()
{
VpcId = vpc.VpcId,
CidrBlock = "10.0.0.0/16",
CdcId = "cluster-lchwgxhs",
AvailabilityZone = zones.Apply(getAvailabilityZonesResult => getAvailabilityZonesResult.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.TencentcloudFunctions;
import com.pulumi.tencentcloud.inputs.GetAvailabilityZonesArgs;
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 zones = TencentcloudFunctions.getAvailabilityZones();
var vpc = new Vpc("vpc", VpcArgs.builder()
.cidrBlock("10.0.0.0/16")
.build());
var subnet = new Subnet("subnet", SubnetArgs.builder()
.vpcId(vpc.vpcId())
.cidrBlock("10.0.0.0/16")
.cdcId("cluster-lchwgxhs")
.availabilityZone(zones.applyValue(getAvailabilityZonesResult -> getAvailabilityZonesResult.zones()[0].name()))
.isMulticast(false)
.build());
}
}
resources:
vpc:
type: tencentcloud:Vpc
properties:
cidrBlock: 10.0.0.0/16
subnet:
type: tencentcloud:Subnet
properties:
vpcId: ${vpc.vpcId}
cidrBlock: 10.0.0.0/16
cdcId: cluster-lchwgxhs
availabilityZone: ${zones.zones[0].name}
isMulticast: false
variables:
zones:
fn::invoke:
function: tencentcloud:getAvailabilityZones
arguments: {}
Create Subnet Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Subnet(name: string, args: SubnetArgs, opts?: CustomResourceOptions);
@overload
def Subnet(resource_name: str,
args: SubnetArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Subnet(resource_name: str,
opts: Optional[ResourceOptions] = None,
availability_zone: Optional[str] = None,
cidr_block: Optional[str] = None,
vpc_id: Optional[str] = None,
cdc_id: Optional[str] = None,
is_multicast: Optional[bool] = None,
name: Optional[str] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None)
func NewSubnet(ctx *Context, name string, args SubnetArgs, opts ...ResourceOption) (*Subnet, error)
public Subnet(string name, SubnetArgs args, CustomResourceOptions? opts = null)
public Subnet(String name, SubnetArgs args)
public Subnet(String name, SubnetArgs args, CustomResourceOptions options)
type: tencentcloud:Subnet
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SubnetArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Subnet Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Subnet resource accepts the following input properties:
- Availability
Zone string - The availability zone within which the subnet should be created.
- Cidr
Block string - A network address block of the subnet.
- Vpc
Id string - ID of the VPC to be associated.
- Cdc
Id string - ID of CDC instance.
- Is
Multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- Name string
- The name of subnet to be created.
- Route
Table stringId - ID of a routing table to which the subnet should be associated.
- Subnet
Id string - ID of the resource.
- Dictionary<string, string>
- Tags of the subnet.
- Availability
Zone string - The availability zone within which the subnet should be created.
- Cidr
Block string - A network address block of the subnet.
- Vpc
Id string - ID of the VPC to be associated.
- Cdc
Id string - ID of CDC instance.
- Is
Multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- Name string
- The name of subnet to be created.
- Route
Table stringId - ID of a routing table to which the subnet should be associated.
- Subnet
Id string - ID of the resource.
- map[string]string
- Tags of the subnet.
- availability
Zone String - The availability zone within which the subnet should be created.
- cidr
Block String - A network address block of the subnet.
- vpc
Id String - ID of the VPC to be associated.
- cdc
Id String - ID of CDC instance.
- is
Multicast Boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name String
- The name of subnet to be created.
- route
Table StringId - ID of a routing table to which the subnet should be associated.
- subnet
Id String - ID of the resource.
- Map<String,String>
- Tags of the subnet.
- availability
Zone string - The availability zone within which the subnet should be created.
- cidr
Block string - A network address block of the subnet.
- vpc
Id string - ID of the VPC to be associated.
- cdc
Id string - ID of CDC instance.
- is
Multicast boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name string
- The name of subnet to be created.
- route
Table stringId - ID of a routing table to which the subnet should be associated.
- subnet
Id string - ID of the resource.
- {[key: string]: string}
- Tags of the subnet.
- availability_
zone str - The availability zone within which the subnet should be created.
- cidr_
block str - A network address block of the subnet.
- vpc_
id str - ID of the VPC to be associated.
- cdc_
id str - ID of CDC instance.
- is_
multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- name str
- The name of subnet to be created.
- route_
table_ strid - ID of a routing table to which the subnet should be associated.
- subnet_
id str - ID of the resource.
- Mapping[str, str]
- Tags of the subnet.
- availability
Zone String - The availability zone within which the subnet should be created.
- cidr
Block String - A network address block of the subnet.
- vpc
Id String - ID of the VPC to be associated.
- cdc
Id String - ID of CDC instance.
- is
Multicast Boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name String
- The name of subnet to be created.
- route
Table StringId - ID of a routing table to which the subnet should be associated.
- subnet
Id String - ID of the resource.
- Map<String>
- Tags of the subnet.
Outputs
All input properties are implicitly available as output properties. Additionally, the Subnet resource produces the following output properties:
- Available
Ip doubleCount - The number of available IPs.
- Create
Time string - Creation time of subnet resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Is
Default bool - Indicates whether it is the default VPC for this region.
- Available
Ip float64Count - The number of available IPs.
- Create
Time string - Creation time of subnet resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- Is
Default bool - Indicates whether it is the default VPC for this region.
- available
Ip DoubleCount - The number of available IPs.
- create
Time String - Creation time of subnet resource.
- id String
- The provider-assigned unique ID for this managed resource.
- is
Default Boolean - Indicates whether it is the default VPC for this region.
- available
Ip numberCount - The number of available IPs.
- create
Time string - Creation time of subnet resource.
- id string
- The provider-assigned unique ID for this managed resource.
- is
Default boolean - Indicates whether it is the default VPC for this region.
- available_
ip_ floatcount - The number of available IPs.
- create_
time str - Creation time of subnet resource.
- id str
- The provider-assigned unique ID for this managed resource.
- is_
default bool - Indicates whether it is the default VPC for this region.
- available
Ip NumberCount - The number of available IPs.
- create
Time String - Creation time of subnet resource.
- id String
- The provider-assigned unique ID for this managed resource.
- is
Default Boolean - Indicates whether it is the default VPC for this region.
Look up Existing Subnet Resource
Get an existing Subnet resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SubnetState, opts?: CustomResourceOptions): Subnet
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
availability_zone: Optional[str] = None,
available_ip_count: Optional[float] = None,
cdc_id: Optional[str] = None,
cidr_block: Optional[str] = None,
create_time: Optional[str] = None,
is_default: Optional[bool] = None,
is_multicast: Optional[bool] = None,
name: Optional[str] = None,
route_table_id: Optional[str] = None,
subnet_id: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
vpc_id: Optional[str] = None) -> Subnet
func GetSubnet(ctx *Context, name string, id IDInput, state *SubnetState, opts ...ResourceOption) (*Subnet, error)
public static Subnet Get(string name, Input<string> id, SubnetState? state, CustomResourceOptions? opts = null)
public static Subnet get(String name, Output<String> id, SubnetState state, CustomResourceOptions options)
resources: _: type: tencentcloud:Subnet get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Availability
Zone string - The availability zone within which the subnet should be created.
- Available
Ip doubleCount - The number of available IPs.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - A network address block of the subnet.
- Create
Time string - Creation time of subnet resource.
- Is
Default bool - Indicates whether it is the default VPC for this region.
- Is
Multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- Name string
- The name of subnet to be created.
- Route
Table stringId - ID of a routing table to which the subnet should be associated.
- Subnet
Id string - ID of the resource.
- Dictionary<string, string>
- Tags of the subnet.
- Vpc
Id string - ID of the VPC to be associated.
- Availability
Zone string - The availability zone within which the subnet should be created.
- Available
Ip float64Count - The number of available IPs.
- Cdc
Id string - ID of CDC instance.
- Cidr
Block string - A network address block of the subnet.
- Create
Time string - Creation time of subnet resource.
- Is
Default bool - Indicates whether it is the default VPC for this region.
- Is
Multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- Name string
- The name of subnet to be created.
- Route
Table stringId - ID of a routing table to which the subnet should be associated.
- Subnet
Id string - ID of the resource.
- map[string]string
- Tags of the subnet.
- Vpc
Id string - ID of the VPC to be associated.
- availability
Zone String - The availability zone within which the subnet should be created.
- available
Ip DoubleCount - The number of available IPs.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - A network address block of the subnet.
- create
Time String - Creation time of subnet resource.
- is
Default Boolean - Indicates whether it is the default VPC for this region.
- is
Multicast Boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name String
- The name of subnet to be created.
- route
Table StringId - ID of a routing table to which the subnet should be associated.
- subnet
Id String - ID of the resource.
- Map<String,String>
- Tags of the subnet.
- vpc
Id String - ID of the VPC to be associated.
- availability
Zone string - The availability zone within which the subnet should be created.
- available
Ip numberCount - The number of available IPs.
- cdc
Id string - ID of CDC instance.
- cidr
Block string - A network address block of the subnet.
- create
Time string - Creation time of subnet resource.
- is
Default boolean - Indicates whether it is the default VPC for this region.
- is
Multicast boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name string
- The name of subnet to be created.
- route
Table stringId - ID of a routing table to which the subnet should be associated.
- subnet
Id string - ID of the resource.
- {[key: string]: string}
- Tags of the subnet.
- vpc
Id string - ID of the VPC to be associated.
- availability_
zone str - The availability zone within which the subnet should be created.
- available_
ip_ floatcount - The number of available IPs.
- cdc_
id str - ID of CDC instance.
- cidr_
block str - A network address block of the subnet.
- create_
time str - Creation time of subnet resource.
- is_
default bool - Indicates whether it is the default VPC for this region.
- is_
multicast bool - Indicates whether multicast is enabled. The default value is 'true'.
- name str
- The name of subnet to be created.
- route_
table_ strid - ID of a routing table to which the subnet should be associated.
- subnet_
id str - ID of the resource.
- Mapping[str, str]
- Tags of the subnet.
- vpc_
id str - ID of the VPC to be associated.
- availability
Zone String - The availability zone within which the subnet should be created.
- available
Ip NumberCount - The number of available IPs.
- cdc
Id String - ID of CDC instance.
- cidr
Block String - A network address block of the subnet.
- create
Time String - Creation time of subnet resource.
- is
Default Boolean - Indicates whether it is the default VPC for this region.
- is
Multicast Boolean - Indicates whether multicast is enabled. The default value is 'true'.
- name String
- The name of subnet to be created.
- route
Table StringId - ID of a routing table to which the subnet should be associated.
- subnet
Id String - ID of the resource.
- Map<String>
- Tags of the subnet.
- vpc
Id String - ID of the VPC to be associated.
Import
Vpc subnet instance can be imported, e.g.
$ pulumi import tencentcloud:index/subnet:Subnet subnet subnet-b8j03v0c
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- tencentcloud tencentcloudstack/terraform-provider-tencentcloud
- License
- Notes
- This Pulumi package is based on the
tencentcloud
Terraform Provider.