1. Packages
  2. Hetzner Cloud
  3. API Docs
  4. NetworkSubnet
Hetzner Cloud v1.18.0 published on Wednesday, Mar 27, 2024 by Pulumi

hcloud.NetworkSubnet

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.18.0 published on Wednesday, Mar 27, 2024 by Pulumi

    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", {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", 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{
    			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()
        {
            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()        
                .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:
          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

    new NetworkSubnet(name: string, args: NetworkSubnetArgs, opts?: CustomResourceOptions);
    @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)
    @overload
    def NetworkSubnet(resource_name: str,
                      args: NetworkSubnetArgs,
                      opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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:

    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 Integer
    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 Integer
    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
    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

    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 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.
    gateway String
    id String
    The provider-assigned unique ID for this managed resource.

    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.
    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 Integer
    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 Integer
    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
    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

    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
    Hetzner Cloud pulumi/pulumi-hcloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the hcloud Terraform Provider.
    hcloud logo
    Hetzner Cloud v1.18.0 published on Wednesday, Mar 27, 2024 by Pulumi