Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

Yandex

v0.10.0 published on Thursday, Nov 18, 2021 by Pulumi

VpcSubnet

Manages a subnet within the Yandex.Cloud. For more information, see the official documentation.

Example Usage

using Pulumi;
using Yandex = Pulumi.Yandex;

class MyStack : Stack
{
    public MyStack()
    {
        var lab_net = new Yandex.VpcNetwork("lab-net", new Yandex.VpcNetworkArgs
        {
        });
        var lab_subnet_a = new Yandex.VpcSubnet("lab-subnet-a", new Yandex.VpcSubnetArgs
        {
            NetworkId = lab_net.Id,
            V4CidrBlocks = 
            {
                "10.2.0.0/16",
            },
            Zone = "ru-central1-a",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-yandex/sdk/go/yandex"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := yandex.NewVpcNetwork(ctx, "lab_net", nil)
		if err != nil {
			return err
		}
		_, err = yandex.NewVpcSubnet(ctx, "lab_subnet_a", &yandex.VpcSubnetArgs{
			NetworkId: lab_net.ID(),
			V4CidrBlocks: pulumi.StringArray{
				pulumi.String("10.2.0.0/16"),
			},
			Zone: pulumi.String("ru-central1-a"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_yandex as yandex

lab_net = yandex.VpcNetwork("lab-net")
lab_subnet_a = yandex.VpcSubnet("lab-subnet-a",
    network_id=lab_net.id,
    v4_cidr_blocks=["10.2.0.0/16"],
    zone="ru-central1-a")
import * as pulumi from "@pulumi/pulumi";
import * as yandex from "@pulumi/yandex";

const lab_net = new yandex.VpcNetwork("lab-net", {});
const lab_subnet_a = new yandex.VpcSubnet("lab-subnet-a", {
    networkId: lab_net.id,
    v4CidrBlocks: ["10.2.0.0/16"],
    zone: "ru-central1-a",
});

Create a VpcSubnet Resource

new VpcSubnet(name: string, args: VpcSubnetArgs, opts?: CustomResourceOptions);
@overload
def VpcSubnet(resource_name: str,
              opts: Optional[ResourceOptions] = None,
              description: Optional[str] = None,
              dhcp_options: Optional[VpcSubnetDhcpOptionsArgs] = None,
              folder_id: Optional[str] = None,
              labels: Optional[Mapping[str, str]] = None,
              name: Optional[str] = None,
              network_id: Optional[str] = None,
              route_table_id: Optional[str] = None,
              v4_cidr_blocks: Optional[Sequence[str]] = None,
              zone: Optional[str] = None)
@overload
def VpcSubnet(resource_name: str,
              args: VpcSubnetArgs,
              opts: Optional[ResourceOptions] = None)
func NewVpcSubnet(ctx *Context, name string, args VpcSubnetArgs, opts ...ResourceOption) (*VpcSubnet, error)
public VpcSubnet(string name, VpcSubnetArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args VpcSubnetArgs
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 VpcSubnetArgs
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 VpcSubnetArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VpcSubnetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

VpcSubnet Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The VpcSubnet resource accepts the following input properties:

NetworkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
V4CidrBlocks List<string>
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
Description string
An optional description of the subnet. Provide this property when you create the resource.
DhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
FolderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
Labels Dictionary<string, string>
Labels to assign to this subnet. A list of key/value pairs.
Name string
Name of the subnet. Provided by the client when the subnet is created.
RouteTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
Zone string
Name of the Yandex.Cloud zone for this subnet.
NetworkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
V4CidrBlocks []string
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
Description string
An optional description of the subnet. Provide this property when you create the resource.
DhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
FolderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
Labels map[string]string
Labels to assign to this subnet. A list of key/value pairs.
Name string
Name of the subnet. Provided by the client when the subnet is created.
RouteTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
Zone string
Name of the Yandex.Cloud zone for this subnet.
networkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
v4CidrBlocks string[]
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
description string
An optional description of the subnet. Provide this property when you create the resource.
dhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
folderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
labels {[key: string]: string}
Labels to assign to this subnet. A list of key/value pairs.
name string
Name of the subnet. Provided by the client when the subnet is created.
routeTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
zone string
Name of the Yandex.Cloud zone for this subnet.
network_id str
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
v4_cidr_blocks Sequence[str]
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
description str
An optional description of the subnet. Provide this property when you create the resource.
dhcp_options VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
folder_id str
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
labels Mapping[str, str]
Labels to assign to this subnet. A list of key/value pairs.
name str
Name of the subnet. Provided by the client when the subnet is created.
route_table_id str
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
zone str
Name of the Yandex.Cloud zone for this subnet.

Outputs

All input properties are implicitly available as output properties. Additionally, the VpcSubnet resource produces the following output properties:

CreatedAt string
Id string
The provider-assigned unique ID for this managed resource.
V6CidrBlocks List<string>
An optional list of blocks of IPv6 addresses that are owned by this subnet.
CreatedAt string
Id string
The provider-assigned unique ID for this managed resource.
V6CidrBlocks []string
An optional list of blocks of IPv6 addresses that are owned by this subnet.
createdAt string
id string
The provider-assigned unique ID for this managed resource.
v6CidrBlocks string[]
An optional list of blocks of IPv6 addresses that are owned by this subnet.
created_at str
id str
The provider-assigned unique ID for this managed resource.
v6_cidr_blocks Sequence[str]
An optional list of blocks of IPv6 addresses that are owned by this subnet.

Look up an Existing VpcSubnet Resource

Get an existing VpcSubnet 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?: VpcSubnetState, opts?: CustomResourceOptions): VpcSubnet
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        created_at: Optional[str] = None,
        description: Optional[str] = None,
        dhcp_options: Optional[VpcSubnetDhcpOptionsArgs] = None,
        folder_id: Optional[str] = None,
        labels: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        network_id: Optional[str] = None,
        route_table_id: Optional[str] = None,
        v4_cidr_blocks: Optional[Sequence[str]] = None,
        v6_cidr_blocks: Optional[Sequence[str]] = None,
        zone: Optional[str] = None) -> VpcSubnet
func GetVpcSubnet(ctx *Context, name string, id IDInput, state *VpcSubnetState, opts ...ResourceOption) (*VpcSubnet, error)
public static VpcSubnet Get(string name, Input<string> id, VpcSubnetState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

CreatedAt string
Description string
An optional description of the subnet. Provide this property when you create the resource.
DhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
FolderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
Labels Dictionary<string, string>
Labels to assign to this subnet. A list of key/value pairs.
Name string
Name of the subnet. Provided by the client when the subnet is created.
NetworkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
RouteTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
V4CidrBlocks List<string>
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
V6CidrBlocks List<string>
An optional list of blocks of IPv6 addresses that are owned by this subnet.
Zone string
Name of the Yandex.Cloud zone for this subnet.
CreatedAt string
Description string
An optional description of the subnet. Provide this property when you create the resource.
DhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
FolderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
Labels map[string]string
Labels to assign to this subnet. A list of key/value pairs.
Name string
Name of the subnet. Provided by the client when the subnet is created.
NetworkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
RouteTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
V4CidrBlocks []string
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
V6CidrBlocks []string
An optional list of blocks of IPv6 addresses that are owned by this subnet.
Zone string
Name of the Yandex.Cloud zone for this subnet.
createdAt string
description string
An optional description of the subnet. Provide this property when you create the resource.
dhcpOptions VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
folderId string
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
labels {[key: string]: string}
Labels to assign to this subnet. A list of key/value pairs.
name string
Name of the subnet. Provided by the client when the subnet is created.
networkId string
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
routeTableId string
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
v4CidrBlocks string[]
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
v6CidrBlocks string[]
An optional list of blocks of IPv6 addresses that are owned by this subnet.
zone string
Name of the Yandex.Cloud zone for this subnet.
created_at str
description str
An optional description of the subnet. Provide this property when you create the resource.
dhcp_options VpcSubnetDhcpOptionsArgs
Options for DHCP client. The structure is documented below.
folder_id str
The ID of the folder to which the resource belongs. If omitted, the provider folder is used.
labels Mapping[str, str]
Labels to assign to this subnet. A list of key/value pairs.
name str
Name of the subnet. Provided by the client when the subnet is created.
network_id str
ID of the network this subnet belongs to. Only networks that are in the distributed mode can have subnets.
route_table_id str
The ID of the route table to assign to this subnet. Assigned route table should belong to the same network as this subnet.
v4_cidr_blocks Sequence[str]
A list of blocks of internal IPv4 addresses that are owned by this subnet. Provide this property when you create the subnet. For example, 10.0.0.0/22 or 192.168.0.0/16. Blocks of addresses must be unique and non-overlapping within a network. Minimum subnet size is /28, and maximum subnet size is /16. Only IPv4 is supported.
v6_cidr_blocks Sequence[str]
An optional list of blocks of IPv6 addresses that are owned by this subnet.
zone str
Name of the Yandex.Cloud zone for this subnet.

Supporting Types

VpcSubnetDhcpOptions

DomainName string
Domain name.
DomainNameServers List<string>
Domain name server IP addresses.
NtpServers List<string>
NTP server IP addresses.
DomainName string
Domain name.
DomainNameServers []string
Domain name server IP addresses.
NtpServers []string
NTP server IP addresses.
domainName string
Domain name.
domainNameServers string[]
Domain name server IP addresses.
ntpServers string[]
NTP server IP addresses.
domain_name str
Domain name.
domain_name_servers Sequence[str]
Domain name server IP addresses.
ntp_servers Sequence[str]
NTP server IP addresses.

Import

A subnet can be imported using the id of the resource, e.g.

 $ pulumi import yandex:index/vpcSubnet:VpcSubnet default subnet_id

Package Details

Repository
https://github.com/pulumi/pulumi-yandex
License
Apache-2.0
Notes
This Pulumi package is based on the yandex Terraform Provider.