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

ServerNetwork

Provides a Hetzner Cloud Server Network to represent a private network on a server in the Hetzner Cloud.

Example Usage

using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var node1 = new HCloud.Server("node1", new HCloud.ServerArgs
        {
            Image = "debian-9",
            ServerType = "cx11",
        });
        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",
        });
        var srvnetwork = new HCloud.ServerNetwork("srvnetwork", new HCloud.ServerNetworkArgs
        {
            ServerId = node1.Id,
            NetworkId = mynet.Id,
            Ip = "10.0.1.5",
        });
    }

}
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 {
        node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
            Image:      pulumi.String("debian-9"),
            ServerType: pulumi.String("cx11"),
        })
        if err != nil {
            return err
        }
        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
        }
        _, err = hcloud.NewServerNetwork(ctx, "srvnetwork", &hcloud.ServerNetworkArgs{
            ServerId:  node1.ID(),
            NetworkId: mynet.ID(),
            Ip:        pulumi.String("10.0.1.5"),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_hcloud as hcloud

node1 = hcloud.Server("node1",
    image="debian-9",
    server_type="cx11")
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")
srvnetwork = hcloud.ServerNetwork("srvnetwork",
    server_id=node1.id,
    network_id=mynet.id,
    ip="10.0.1.5")
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const node1 = new hcloud.Server("node1", {
    image: "debian-9",
    serverType: "cx11",
});
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",
});
const srvnetwork = new hcloud.ServerNetwork("srvnetwork", {
    serverId: node1.id,
    networkId: mynet.id,
    ip: "10.0.1.5",
});

Create a ServerNetwork Resource

new ServerNetwork(name: string, args: ServerNetworkArgs, opts?: CustomResourceOptions);
def ServerNetwork(resource_name: str, opts: Optional[ResourceOptions] = None, alias_ips: Optional[Sequence[str]] = None, ip: Optional[str] = None, network_id: Optional[int] = None, server_id: Optional[int] = None, subnet_id: Optional[str] = None)
func NewServerNetwork(ctx *Context, name string, args ServerNetworkArgs, opts ...ResourceOption) (*ServerNetwork, error)
public ServerNetwork(string name, ServerNetworkArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ServerNetworkArgs
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 ServerNetworkArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ServerNetworkArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

ServerNetwork Resource Properties

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

Inputs

The ServerNetwork resource accepts the following input properties:

ServerId int

ID of the server.

AliasIps List<string>

Additional IPs to be assigned to this server.

Ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

NetworkId int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

SubnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

ServerId int

ID of the server.

AliasIps []string

Additional IPs to be assigned to this server.

Ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

NetworkId int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

SubnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

serverId number

ID of the server.

aliasIps string[]

Additional IPs to be assigned to this server.

ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

networkId number

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

subnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

server_id int

ID of the server.

alias_ips Sequence[str]

Additional IPs to be assigned to this server.

ip str

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

network_id int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

subnet_id str

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
MacAddress string
Id string
The provider-assigned unique ID for this managed resource.
MacAddress string
id string
The provider-assigned unique ID for this managed resource.
macAddress string
id str
The provider-assigned unique ID for this managed resource.
mac_address str

Look up an Existing ServerNetwork Resource

Get an existing ServerNetwork 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?: ServerNetworkState, opts?: CustomResourceOptions): ServerNetwork
@staticmethod
def get(resource_name: str, id: str, opts: Optional[ResourceOptions] = None, alias_ips: Optional[Sequence[str]] = None, ip: Optional[str] = None, mac_address: Optional[str] = None, network_id: Optional[int] = None, server_id: Optional[int] = None, subnet_id: Optional[str] = None) -> ServerNetwork
func GetServerNetwork(ctx *Context, name string, id IDInput, state *ServerNetworkState, opts ...ResourceOption) (*ServerNetwork, error)
public static ServerNetwork Get(string name, Input<string> id, ServerNetworkState? 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:

AliasIps List<string>

Additional IPs to be assigned to this server.

Ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

MacAddress string
NetworkId int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

ServerId int

ID of the server.

SubnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

AliasIps []string

Additional IPs to be assigned to this server.

Ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

MacAddress string
NetworkId int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

ServerId int

ID of the server.

SubnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

aliasIps string[]

Additional IPs to be assigned to this server.

ip string

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

macAddress string
networkId number

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

serverId number

ID of the server.

subnetId string

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

alias_ips Sequence[str]

Additional IPs to be assigned to this server.

ip str

IP to request to be assigned to this server. If you do not provide this then you will be auto assigned an IP address.

mac_address str
network_id int

ID of the network which should be added to the server. Required if subnet_id is not set. Successful creation of the resource depends on the existence of a subnet in the Hetzner Cloud Backend. Using network_id will not create an explicit dependency between server and subnet. Therefore depends_on may need to be used. Alternatively the subnet_id property can be used, which will create an explicit dependency between hcloud.ServerNetwork and the existence of a subnet.

server_id int

ID of the server.

subnet_id str

ID of the sub-network which should be added to the Server. Required if network_id is not set. Note: if the ip property is missing, the Server is currently added to the last created subnet.

Import

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

 $ pulumi import hcloud:index/serverNetwork:ServerNetwork myservernetwork 123-654

Package Details

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