Ready to level-up your engineering skills? Join a Pulumi Workshop. Register Now

NetworkSubnet

Provides a Hetzner Cloud Network Subnet to represent a Subnet in the Hetzner Cloud.

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var mynet = new HCloud.Network("mynet", new HCloud.NetworkArgs
        {
            IpRange = "10.0.0.0/8",
        });
        var foonet = new HCloud.NetworkSubnet("foonet", new HCloud.NetworkSubnetArgs
        {
            NetworkId = mynet.Id,
            Type = "cloud",
            NetworkZone = "eu-central",
            IpRange = "10.0.1.0/24",
        });
    }

}
package main

import (
    "github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        mynet, err := hcloud.NewNetwork(ctx, "mynet", &hcloud.NetworkArgs{
            IpRange: pulumi.String("10.0.0.0/8"),
        })
        if err != nil {
            return err
        }
        _, err = hcloud.NewNetworkSubnet(ctx, "foonet", &hcloud.NetworkSubnetArgs{
            NetworkId:   mynet.ID(),
            Type:        pulumi.String("cloud"),
            NetworkZone: pulumi.String("eu-central"),
            IpRange:     pulumi.String("10.0.1.0/24"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_hcloud as hcloud

mynet = hcloud.Network("mynet", ip_range="10.0.0.0/8")
foonet = hcloud.NetworkSubnet("foonet",
    network_id=mynet.id,
    type="cloud",
    network_zone="eu-central",
    ip_range="10.0.1.0/24")
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const mynet = new hcloud.Network("mynet", {ipRange: "10.0.0.0/8"});
const foonet = new hcloud.NetworkSubnet("foonet", {
    networkId: mynet.id,
    type: "cloud",
    networkZone: "eu-central",
    ipRange: "10.0.1.0/24",
});

Create a NetworkSubnet Resource

new NetworkSubnet(name: string, args: NetworkSubnetArgs, opts?: CustomResourceOptions);
def NetworkSubnet(resource_name: str, opts: Optional[ResourceOptions] = None, ip_range: Optional[str] = None, network_id: Optional[int] = None, network_zone: Optional[str] = None, type: Optional[str] = None, vswitch_id: Optional[int] = None)
func NewNetworkSubnet(ctx *Context, name string, args NetworkSubnetArgs, opts ...ResourceOption) (*NetworkSubnet, error)
public NetworkSubnet(string name, NetworkSubnetArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args NetworkSubnetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
opts ResourceOptions
A bag of options that control this resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NetworkSubnetArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NetworkSubnetArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

NetworkSubnet Resource Properties

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

Inputs

The NetworkSubnet resource accepts the following input properties:

IpRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

NetworkId int

ID of the Network the subnet should be added to.

NetworkZone string

Name of network zone.

Type string

Type of subnet. server, cloud or vswitch

VswitchId int

ID of the vswitch, Required if type is vswitch

IpRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

NetworkId int

ID of the Network the subnet should be added to.

NetworkZone string

Name of network zone.

Type string

Type of subnet. server, cloud or vswitch

VswitchId int

ID of the vswitch, Required if type is vswitch

ipRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

networkId number

ID of the Network the subnet should be added to.

networkZone string

Name of network zone.

type string

Type of subnet. server, cloud or vswitch

vswitchId number

ID of the vswitch, Required if type is vswitch

ip_range str

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

network_id int

ID of the Network the subnet should be added to.

network_zone str

Name of network zone.

type str

Type of subnet. server, cloud or vswitch

vswitch_id int

ID of the vswitch, Required if type is vswitch

Outputs

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

Gateway string
Id string
The provider-assigned unique ID for this managed resource.
Gateway string
Id string
The provider-assigned unique ID for this managed resource.
gateway string
id string
The provider-assigned unique ID for this managed resource.
gateway str
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing NetworkSubnet Resource

Get an existing NetworkSubnet 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?: NetworkSubnetState, opts?: CustomResourceOptions): NetworkSubnet
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, gateway: Optional[str] = None, ip_range: Optional[str] = None, network_id: Optional[int] = None, network_zone: Optional[str] = None, type: Optional[str] = None, vswitch_id: Optional[int] = None) -> NetworkSubnet
func GetNetworkSubnet(ctx *Context, name string, id IDInput, state *NetworkSubnetState, opts ...ResourceOption) (*NetworkSubnet, error)
public static NetworkSubnet Get(string name, Input<string> id, NetworkSubnetState? 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:

Gateway string
IpRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

NetworkId int

ID of the Network the subnet should be added to.

NetworkZone string

Name of network zone.

Type string

Type of subnet. server, cloud or vswitch

VswitchId int

ID of the vswitch, Required if type is vswitch

Gateway string
IpRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

NetworkId int

ID of the Network the subnet should be added to.

NetworkZone string

Name of network zone.

Type string

Type of subnet. server, cloud or vswitch

VswitchId int

ID of the vswitch, Required if type is vswitch

gateway string
ipRange string

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

networkId number

ID of the Network the subnet should be added to.

networkZone string

Name of network zone.

type string

Type of subnet. server, cloud or vswitch

vswitchId number

ID of the vswitch, Required if type is vswitch

gateway str
ip_range str

Range to allocate IPs from. Must be a subnet of the ip_range of the Network and must not overlap with any other subnets or with any destinations in routes.

network_id int

ID of the Network the subnet should be added to.

network_zone str

Name of network zone.

type str

Type of subnet. server, cloud or vswitch

vswitch_id int

ID of the vswitch, Required if type is vswitch

Import

Network Subnet entries can be imported using a compound ID with the following format<network-id>-<ip_range>

 $ pulumi import hcloud:index/networkSubnet:NetworkSubnet mysubnet 123-10.0.0.0/24

Package Details

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