hcloud.NetworkSubnet
Explore with Pulumi AI
Provides a Hetzner Cloud Network Subnet to represent a Subnet in the Hetzner Cloud.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const mynet = new hcloud.Network("mynet", {
name: "my-net",
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",
});
import pulumi
import pulumi_hcloud as hcloud
mynet = hcloud.Network("mynet",
name="my-net",
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")
package main
import (
"github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
mynet, err := hcloud.NewNetwork(ctx, "mynet", &hcloud.NetworkArgs{
Name: pulumi.String("my-net"),
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
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;
return await Deployment.RunAsync(() =>
{
var mynet = new HCloud.Network("mynet", new()
{
Name = "my-net",
IpRange = "10.0.0.0/8",
});
var foonet = new HCloud.NetworkSubnet("foonet", new()
{
NetworkId = mynet.Id,
Type = "cloud",
NetworkZone = "eu-central",
IpRange = "10.0.1.0/24",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.Network;
import com.pulumi.hcloud.NetworkArgs;
import com.pulumi.hcloud.NetworkSubnet;
import com.pulumi.hcloud.NetworkSubnetArgs;
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) {
var mynet = new Network("mynet", NetworkArgs.builder()
.name("my-net")
.ipRange("10.0.0.0/8")
.build());
var foonet = new NetworkSubnet("foonet", NetworkSubnetArgs.builder()
.networkId(mynet.id())
.type("cloud")
.networkZone("eu-central")
.ipRange("10.0.1.0/24")
.build());
}
}
resources:
mynet:
type: hcloud:Network
properties:
name: my-net
ipRange: 10.0.0.0/8
foonet:
type: hcloud:NetworkSubnet
properties:
networkId: ${mynet.id}
type: cloud
networkZone: eu-central
ipRange: 10.0.1.0/24
Create NetworkSubnet Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NetworkSubnet(name: string, args: NetworkSubnetArgs, opts?: CustomResourceOptions);
@overload
def NetworkSubnet(resource_name: str,
args: NetworkSubnetArgs,
opts: Optional[ResourceOptions] = None)
@overload
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)
public NetworkSubnet(String name, NetworkSubnetArgs args)
public NetworkSubnet(String name, NetworkSubnetArgs args, CustomResourceOptions options)
type: hcloud:NetworkSubnet
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 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.
- args NetworkSubnetArgs
- 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 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.
- name String
- The unique name of the resource.
- args NetworkSubnetArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var networkSubnetResource = new HCloud.NetworkSubnet("networkSubnetResource", new()
{
IpRange = "string",
NetworkId = 0,
NetworkZone = "string",
Type = "string",
VswitchId = 0,
});
example, err := hcloud.NewNetworkSubnet(ctx, "networkSubnetResource", &hcloud.NetworkSubnetArgs{
IpRange: pulumi.String("string"),
NetworkId: pulumi.Int(0),
NetworkZone: pulumi.String("string"),
Type: pulumi.String("string"),
VswitchId: pulumi.Int(0),
})
var networkSubnetResource = new NetworkSubnet("networkSubnetResource", NetworkSubnetArgs.builder()
.ipRange("string")
.networkId(0)
.networkZone("string")
.type("string")
.vswitchId(0)
.build());
network_subnet_resource = hcloud.NetworkSubnet("networkSubnetResource",
ip_range="string",
network_id=0,
network_zone="string",
type="string",
vswitch_id=0)
const networkSubnetResource = new hcloud.NetworkSubnet("networkSubnetResource", {
ipRange: "string",
networkId: 0,
networkZone: "string",
type: "string",
vswitchId: 0,
});
type: hcloud:NetworkSubnet
properties:
ipRange: string
networkId: 0
networkZone: string
type: string
vswitchId: 0
NetworkSubnet 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 NetworkSubnet resource accepts the following input properties:
- Ip
Range 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.
- Network
Id int - ID of the Network the subnet should be added to.
- Network
Zone string - Name of network zone.
- Type string
- Type of subnet.
server
,cloud
orvswitch
- Vswitch
Id int - ID of the vswitch, Required if type is
vswitch
- Ip
Range 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.
- Network
Id int - ID of the Network the subnet should be added to.
- Network
Zone string - Name of network zone.
- Type string
- Type of subnet.
server
,cloud
orvswitch
- Vswitch
Id int - ID of the vswitch, Required if type is
vswitch
- ip
Range 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.
- network
Id Integer - ID of the Network the subnet should be added to.
- network
Zone String - Name of network zone.
- type String
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id Integer - ID of the vswitch, Required if type is
vswitch
- ip
Range 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.
- network
Id number - ID of the Network the subnet should be added to.
- network
Zone string - Name of network zone.
- type string
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id 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
orvswitch
- vswitch_
id int - ID of the vswitch, Required if type is
vswitch
- ip
Range 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.
- network
Id Number - ID of the Network the subnet should be added to.
- network
Zone String - Name of network zone.
- type String
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id Number - 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:
Look up 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)
public static NetworkSubnet get(String name, Output<String> id, NetworkSubnetState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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.
- Gateway string
- Ip
Range 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.
- Network
Id int - ID of the Network the subnet should be added to.
- Network
Zone string - Name of network zone.
- Type string
- Type of subnet.
server
,cloud
orvswitch
- Vswitch
Id int - ID of the vswitch, Required if type is
vswitch
- Gateway string
- Ip
Range 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.
- Network
Id int - ID of the Network the subnet should be added to.
- Network
Zone string - Name of network zone.
- Type string
- Type of subnet.
server
,cloud
orvswitch
- Vswitch
Id int - ID of the vswitch, Required if type is
vswitch
- gateway String
- ip
Range 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.
- network
Id Integer - ID of the Network the subnet should be added to.
- network
Zone String - Name of network zone.
- type String
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id Integer - ID of the vswitch, Required if type is
vswitch
- gateway string
- ip
Range 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.
- network
Id number - ID of the Network the subnet should be added to.
- network
Zone string - Name of network zone.
- type string
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id 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
orvswitch
- vswitch_
id int - ID of the vswitch, Required if type is
vswitch
- gateway String
- ip
Range 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.
- network
Id Number - ID of the Network the subnet should be added to.
- network
Zone String - Name of network zone.
- type String
- Type of subnet.
server
,cloud
orvswitch
- vswitch
Id Number - 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
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Hetzner Cloud pulumi/pulumi-hcloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
hcloud
Terraform Provider.