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

hcloud.Server

Explore with Pulumi AI

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

    Provides an Hetzner Cloud server resource. This can be used to create, modify, and delete servers. Servers also support provisioning.

    Example Usage

    Basic server creation

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    // Create a new server running debian
    const node1 = new hcloud.Server("node1", {
        image: "debian-11",
        publicNets: [{
            ipv4Enabled: true,
            ipv6Enabled: true,
        }],
        serverType: "cx11",
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    # Create a new server running debian
    node1 = hcloud.Server("node1",
        image="debian-11",
        public_nets=[hcloud.ServerPublicNetArgs(
            ipv4_enabled=True,
            ipv6_enabled=True,
        )],
        server_type="cx11")
    
    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 {
    		// Create a new server running debian
    		_, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
    			Image: pulumi.String("debian-11"),
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv6Enabled: pulumi.Bool(true),
    				},
    			},
    			ServerType: pulumi.String("cx11"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        // Create a new server running debian
        var node1 = new HCloud.Server("node1", new()
        {
            Image = "debian-11",
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv6Enabled = true,
                },
            },
            ServerType = "cx11",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.inputs.ServerPublicNetArgs;
    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 node1 = new Server("node1", ServerArgs.builder()        
                .image("debian-11")
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv6Enabled(true)
                    .build())
                .serverType("cx11")
                .build());
    
        }
    }
    
    resources:
      # Create a new server running debian
      node1:
        type: hcloud:Server
        properties:
          image: debian-11
          publicNets:
            - ipv4Enabled: true
              ipv6Enabled: true
          serverType: cx11
    
    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    //## Server creation with one linked primary ip (ipv4)
    const primaryIp1 = new hcloud.PrimaryIp("primaryIp1", {
        datacenter: "fsn1-dc14",
        type: "ipv4",
        assigneeType: "server",
        autoDelete: true,
        labels: {
            hallo: "welt",
        },
    });
    const serverTest = new hcloud.Server("serverTest", {
        image: "ubuntu-20.04",
        serverType: "cx11",
        datacenter: "fsn1-dc14",
        labels: {
            test: "tessst1",
        },
        publicNets: [{
            ipv4Enabled: true,
            ipv4: primaryIp1.id,
            ipv6Enabled: false,
        }],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    ### Server creation with one linked primary ip (ipv4)
    primary_ip1 = hcloud.PrimaryIp("primaryIp1",
        datacenter="fsn1-dc14",
        type="ipv4",
        assignee_type="server",
        auto_delete=True,
        labels={
            "hallo": "welt",
        })
    server_test = hcloud.Server("serverTest",
        image="ubuntu-20.04",
        server_type="cx11",
        datacenter="fsn1-dc14",
        labels={
            "test": "tessst1",
        },
        public_nets=[hcloud.ServerPublicNetArgs(
            ipv4_enabled=True,
            ipv4=primary_ip1.id,
            ipv6_enabled=False,
        )])
    
    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 {
    		// ## Server creation with one linked primary ip (ipv4)
    		primaryIp1, err := hcloud.NewPrimaryIp(ctx, "primaryIp1", &hcloud.PrimaryIpArgs{
    			Datacenter:   pulumi.String("fsn1-dc14"),
    			Type:         pulumi.String("ipv4"),
    			AssigneeType: pulumi.String("server"),
    			AutoDelete:   pulumi.Bool(true),
    			Labels: pulumi.Map{
    				"hallo": pulumi.Any("welt"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewServer(ctx, "serverTest", &hcloud.ServerArgs{
    			Image:      pulumi.String("ubuntu-20.04"),
    			ServerType: pulumi.String("cx11"),
    			Datacenter: pulumi.String("fsn1-dc14"),
    			Labels: pulumi.Map{
    				"test": pulumi.Any("tessst1"),
    			},
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv4:        primaryIp1.ID(),
    					Ipv6Enabled: pulumi.Bool(false),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        //## Server creation with one linked primary ip (ipv4)
        var primaryIp1 = new HCloud.PrimaryIp("primaryIp1", new()
        {
            Datacenter = "fsn1-dc14",
            Type = "ipv4",
            AssigneeType = "server",
            AutoDelete = true,
            Labels = 
            {
                { "hallo", "welt" },
            },
        });
    
        var serverTest = new HCloud.Server("serverTest", new()
        {
            Image = "ubuntu-20.04",
            ServerType = "cx11",
            Datacenter = "fsn1-dc14",
            Labels = 
            {
                { "test", "tessst1" },
            },
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv4 = primaryIp1.Id,
                    Ipv6Enabled = false,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.PrimaryIp;
    import com.pulumi.hcloud.PrimaryIpArgs;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.inputs.ServerPublicNetArgs;
    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 primaryIp1 = new PrimaryIp("primaryIp1", PrimaryIpArgs.builder()        
                .datacenter("fsn1-dc14")
                .type("ipv4")
                .assigneeType("server")
                .autoDelete(true)
                .labels(Map.of("hallo", "welt"))
                .build());
    
            var serverTest = new Server("serverTest", ServerArgs.builder()        
                .image("ubuntu-20.04")
                .serverType("cx11")
                .datacenter("fsn1-dc14")
                .labels(Map.of("test", "tessst1"))
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv4(primaryIp1.id())
                    .ipv6Enabled(false)
                    .build())
                .build());
    
        }
    }
    
    resources:
      ### Server creation with one linked primary ip (ipv4)
      primaryIp1:
        type: hcloud:PrimaryIp
        properties:
          datacenter: fsn1-dc14
          type: ipv4
          assigneeType: server
          autoDelete: true
          labels:
            hallo: welt
      serverTest:
        type: hcloud:Server
        properties:
          image: ubuntu-20.04
          serverType: cx11
          datacenter: fsn1-dc14
          labels:
            test: tessst1
          publicNets:
            - ipv4Enabled: true
              ipv4: ${primaryIp1.id}
              ipv6Enabled: false
    

    Server creation with network

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const network = new hcloud.Network("network", {ipRange: "10.0.0.0/16"});
    const network_subnet = new hcloud.NetworkSubnet("network-subnet", {
        type: "cloud",
        networkId: network.id,
        networkZone: "eu-central",
        ipRange: "10.0.1.0/24",
    });
    const server = new hcloud.Server("server", {
        serverType: "cx11",
        image: "ubuntu-20.04",
        location: "nbg1",
        networks: [{
            networkId: network.id,
            ip: "10.0.1.5",
            aliasIps: [
                "10.0.1.6",
                "10.0.1.7",
            ],
        }],
    }, {
        dependsOn: [network_subnet],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    network = hcloud.Network("network", ip_range="10.0.0.0/16")
    network_subnet = hcloud.NetworkSubnet("network-subnet",
        type="cloud",
        network_id=network.id,
        network_zone="eu-central",
        ip_range="10.0.1.0/24")
    server = hcloud.Server("server",
        server_type="cx11",
        image="ubuntu-20.04",
        location="nbg1",
        networks=[hcloud.ServerNetworkArgs(
            network_id=network.id,
            ip="10.0.1.5",
            alias_ips=[
                "10.0.1.6",
                "10.0.1.7",
            ],
        )],
        opts=pulumi.ResourceOptions(depends_on=[network_subnet]))
    
    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 {
    		network, err := hcloud.NewNetwork(ctx, "network", &hcloud.NetworkArgs{
    			IpRange: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewNetworkSubnet(ctx, "network-subnet", &hcloud.NetworkSubnetArgs{
    			Type:        pulumi.String("cloud"),
    			NetworkId:   network.ID(),
    			NetworkZone: pulumi.String("eu-central"),
    			IpRange:     pulumi.String("10.0.1.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewServer(ctx, "server", &hcloud.ServerArgs{
    			ServerType: pulumi.String("cx11"),
    			Image:      pulumi.String("ubuntu-20.04"),
    			Location:   pulumi.String("nbg1"),
    			Networks: hcloud.ServerNetworkTypeArray{
    				&hcloud.ServerNetworkTypeArgs{
    					NetworkId: network.ID(),
    					Ip:        pulumi.String("10.0.1.5"),
    					AliasIps: pulumi.StringArray{
    						pulumi.String("10.0.1.6"),
    						pulumi.String("10.0.1.7"),
    					},
    				},
    			},
    		}, pulumi.DependsOn([]pulumi.Resource{
    			network_subnet,
    		}))
    		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 network = new HCloud.Network("network", new()
        {
            IpRange = "10.0.0.0/16",
        });
    
        var network_subnet = new HCloud.NetworkSubnet("network-subnet", new()
        {
            Type = "cloud",
            NetworkId = network.Id,
            NetworkZone = "eu-central",
            IpRange = "10.0.1.0/24",
        });
    
        var server = new HCloud.Server("server", new()
        {
            ServerType = "cx11",
            Image = "ubuntu-20.04",
            Location = "nbg1",
            Networks = new[]
            {
                new HCloud.Inputs.ServerNetworkArgs
                {
                    NetworkId = network.Id,
                    Ip = "10.0.1.5",
                    AliasIps = new[]
                    {
                        "10.0.1.6",
                        "10.0.1.7",
                    },
                },
            },
        }, new CustomResourceOptions
        {
            DependsOn = new[]
            {
                network_subnet,
            },
        });
    
    });
    
    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 com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.inputs.ServerNetworkArgs;
    import com.pulumi.resources.CustomResourceOptions;
    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 network = new Network("network", NetworkArgs.builder()        
                .ipRange("10.0.0.0/16")
                .build());
    
            var network_subnet = new NetworkSubnet("network-subnet", NetworkSubnetArgs.builder()        
                .type("cloud")
                .networkId(network.id())
                .networkZone("eu-central")
                .ipRange("10.0.1.0/24")
                .build());
    
            var server = new Server("server", ServerArgs.builder()        
                .serverType("cx11")
                .image("ubuntu-20.04")
                .location("nbg1")
                .networks(ServerNetworkArgs.builder()
                    .networkId(network.id())
                    .ip("10.0.1.5")
                    .aliasIps(                
                        "10.0.1.6",
                        "10.0.1.7")
                    .build())
                .build(), CustomResourceOptions.builder()
                    .dependsOn(network_subnet)
                    .build());
    
        }
    }
    
    resources:
      network:
        type: hcloud:Network
        properties:
          ipRange: 10.0.0.0/16
      network-subnet:
        type: hcloud:NetworkSubnet
        properties:
          type: cloud
          networkId: ${network.id}
          networkZone: eu-central
          ipRange: 10.0.1.0/24
      server:
        type: hcloud:Server
        properties:
          serverType: cx11
          image: ubuntu-20.04
          location: nbg1
          networks:
            - networkId: ${network.id}
              ip: 10.0.1.5
              aliasIps:
                - 10.0.1.6
                - 10.0.1.7
        options:
          dependson:
            - ${["network-subnet"]}
    

    Server creation from snapshot

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const packerSnapshot = hcloud.getImage({
        withSelector: "app=foobar",
        mostRecent: true,
    });
    // Create a new server from the snapshot
    const fromSnapshot = new hcloud.Server("fromSnapshot", {
        image: packerSnapshot.then(packerSnapshot => packerSnapshot.id),
        serverType: "cx11",
        publicNets: [{
            ipv4Enabled: true,
            ipv6Enabled: true,
        }],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    packer_snapshot = hcloud.get_image(with_selector="app=foobar",
        most_recent=True)
    # Create a new server from the snapshot
    from_snapshot = hcloud.Server("fromSnapshot",
        image=packer_snapshot.id,
        server_type="cx11",
        public_nets=[hcloud.ServerPublicNetArgs(
            ipv4_enabled=True,
            ipv6_enabled=True,
        )])
    
    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 {
    		packerSnapshot, err := hcloud.GetImage(ctx, &hcloud.GetImageArgs{
    			WithSelector: pulumi.StringRef("app=foobar"),
    			MostRecent:   pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		// Create a new server from the snapshot
    		_, err = hcloud.NewServer(ctx, "fromSnapshot", &hcloud.ServerArgs{
    			Image:      pulumi.Int(packerSnapshot.Id),
    			ServerType: pulumi.String("cx11"),
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv6Enabled: pulumi.Bool(true),
    				},
    			},
    		})
    		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 packerSnapshot = HCloud.GetImage.Invoke(new()
        {
            WithSelector = "app=foobar",
            MostRecent = true,
        });
    
        // Create a new server from the snapshot
        var fromSnapshot = new HCloud.Server("fromSnapshot", new()
        {
            Image = packerSnapshot.Apply(getImageResult => getImageResult.Id),
            ServerType = "cx11",
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv6Enabled = true,
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.HcloudFunctions;
    import com.pulumi.hcloud.inputs.GetImageArgs;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.inputs.ServerPublicNetArgs;
    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) {
            final var packerSnapshot = HcloudFunctions.getImage(GetImageArgs.builder()
                .withSelector("app=foobar")
                .mostRecent(true)
                .build());
    
            var fromSnapshot = new Server("fromSnapshot", ServerArgs.builder()        
                .image(packerSnapshot.applyValue(getImageResult -> getImageResult.id()))
                .serverType("cx11")
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv6Enabled(true)
                    .build())
                .build());
    
        }
    }
    
    resources:
      # Create a new server from the snapshot
      fromSnapshot:
        type: hcloud:Server
        properties:
          image: ${packerSnapshot.id}
          serverType: cx11
          publicNets:
            - ipv4Enabled: true
              ipv6Enabled: true
    variables:
      packerSnapshot:
        fn::invoke:
          Function: hcloud:getImage
          Arguments:
            withSelector: app=foobar
            mostRecent: true
    

    Primary IPs

    When creating a server without linking at least one ´primary_ip´, it automatically creates & assigns two (ipv4 & ipv6). With the public_net block, you can enable or link primary ips. If you don’t define this block, two primary ips (ipv4, ipv6) will be created and assigned to the server automatically.

    Examples

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    // Assign existing ipv4 only
    const serverTestServer = new hcloud.Server("serverTestServer", {publicNets: [{
        ipv4Enabled: true,
        ipv4: hcloud_primary_ip.primary_ip_1.id,
        ipv6Enabled: false,
    }]});
    //...
    // Link a managed ipv4 but autogenerate ipv6
    const serverTestIndex_serverServer = new hcloud.Server("serverTestIndex/serverServer", {publicNets: [{
        ipv4Enabled: true,
        ipv4: hcloud_primary_ip.primary_ip_1.id,
        ipv6Enabled: true,
    }]});
    //...
    // Assign & create auto-generated ipv4 & ipv6
    const serverTestHcloudIndex_serverServer = new hcloud.Server("serverTestHcloudIndex/serverServer", {publicNets: [{
        ipv4Enabled: true,
        ipv6Enabled: true,
    }]});
    //...
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    # Assign existing ipv4 only
    server_test_server = hcloud.Server("serverTestServer", public_nets=[hcloud.ServerPublicNetArgs(
        ipv4_enabled=True,
        ipv4=hcloud_primary_ip["primary_ip_1"]["id"],
        ipv6_enabled=False,
    )])
    #...
    # Link a managed ipv4 but autogenerate ipv6
    server_test_index_server_server = hcloud.Server("serverTestIndex/serverServer", public_nets=[hcloud.ServerPublicNetArgs(
        ipv4_enabled=True,
        ipv4=hcloud_primary_ip["primary_ip_1"]["id"],
        ipv6_enabled=True,
    )])
    #...
    # Assign & create auto-generated ipv4 & ipv6
    server_test_hcloud_index_server_server = hcloud.Server("serverTestHcloudIndex/serverServer", public_nets=[hcloud.ServerPublicNetArgs(
        ipv4_enabled=True,
        ipv6_enabled=True,
    )])
    #...
    
    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 {
    		// Assign existing ipv4 only
    		_, err := hcloud.NewServer(ctx, "serverTestServer", &hcloud.ServerArgs{
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv4:        pulumi.Any(hcloud_primary_ip.Primary_ip_1.Id),
    					Ipv6Enabled: pulumi.Bool(false),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Link a managed ipv4 but autogenerate ipv6
    		_, err = hcloud.NewServer(ctx, "serverTestIndex/serverServer", &hcloud.ServerArgs{
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv4:        pulumi.Any(hcloud_primary_ip.Primary_ip_1.Id),
    					Ipv6Enabled: pulumi.Bool(true),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Assign & create auto-generated ipv4 & ipv6
    		_, err = hcloud.NewServer(ctx, "serverTestHcloudIndex/serverServer", &hcloud.ServerArgs{
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4Enabled: pulumi.Bool(true),
    					Ipv6Enabled: pulumi.Bool(true),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        // Assign existing ipv4 only
        var serverTestServer = new HCloud.Server("serverTestServer", new()
        {
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv4 = hcloud_primary_ip.Primary_ip_1.Id,
                    Ipv6Enabled = false,
                },
            },
        });
    
        //...
        // Link a managed ipv4 but autogenerate ipv6
        var serverTestIndex_serverServer = new HCloud.Server("serverTestIndex/serverServer", new()
        {
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv4 = hcloud_primary_ip.Primary_ip_1.Id,
                    Ipv6Enabled = true,
                },
            },
        });
    
        //...
        // Assign & create auto-generated ipv4 & ipv6
        var serverTestHcloudIndex_serverServer = new HCloud.Server("serverTestHcloudIndex/serverServer", new()
        {
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    Ipv4Enabled = true,
                    Ipv6Enabled = true,
                },
            },
        });
    
        //...
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.hcloud.Server;
    import com.pulumi.hcloud.ServerArgs;
    import com.pulumi.hcloud.inputs.ServerPublicNetArgs;
    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 serverTestServer = new Server("serverTestServer", ServerArgs.builder()        
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv4(hcloud_primary_ip.primary_ip_1().id())
                    .ipv6Enabled(false)
                    .build())
                .build());
    
            var serverTestIndex_serverServer = new Server("serverTestIndex/serverServer", ServerArgs.builder()        
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv4(hcloud_primary_ip.primary_ip_1().id())
                    .ipv6Enabled(true)
                    .build())
                .build());
    
            var serverTestHcloudIndex_serverServer = new Server("serverTestHcloudIndex/serverServer", ServerArgs.builder()        
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4Enabled(true)
                    .ipv6Enabled(true)
                    .build())
                .build());
    
        }
    }
    
    resources:
      # Assign existing ipv4 only
      serverTestServer:
        type: hcloud:Server
        properties:
          # ...
          publicNets:
            - ipv4Enabled: true
              ipv4: ${hcloud_primary_ip.primary_ip_1.id}
              ipv6Enabled: false
      # Link a managed ipv4 but autogenerate ipv6
      serverTestIndex/serverServer:
        type: hcloud:Server
        properties:
          # ...
          publicNets:
            - ipv4Enabled: true
              ipv4: ${hcloud_primary_ip.primary_ip_1.id}
              ipv6Enabled: true
      # Assign & create auto-generated ipv4 & ipv6
      serverTestHcloudIndex/serverServer:
        type: hcloud:Server
        properties:
          # ...
          publicNets:
            - ipv4Enabled: true
              ipv6Enabled: true
    

    Create Server Resource

    new Server(name: string, args: ServerArgs, opts?: CustomResourceOptions);
    @overload
    def Server(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               allow_deprecated_images: Optional[bool] = None,
               backups: Optional[bool] = None,
               datacenter: Optional[str] = None,
               delete_protection: Optional[bool] = None,
               firewall_ids: Optional[Sequence[int]] = None,
               ignore_remote_firewall_ids: Optional[bool] = None,
               image: Optional[str] = None,
               iso: Optional[str] = None,
               keep_disk: Optional[bool] = None,
               labels: Optional[Mapping[str, Any]] = None,
               location: Optional[str] = None,
               name: Optional[str] = None,
               networks: Optional[Sequence[ServerNetworkArgs]] = None,
               placement_group_id: Optional[int] = None,
               public_nets: Optional[Sequence[ServerPublicNetArgs]] = None,
               rebuild_protection: Optional[bool] = None,
               rescue: Optional[str] = None,
               server_type: Optional[str] = None,
               shutdown_before_deletion: Optional[bool] = None,
               ssh_keys: Optional[Sequence[str]] = None,
               user_data: Optional[str] = None)
    @overload
    def Server(resource_name: str,
               args: ServerArgs,
               opts: Optional[ResourceOptions] = None)
    func NewServer(ctx *Context, name string, args ServerArgs, opts ...ResourceOption) (*Server, error)
    public Server(string name, ServerArgs args, CustomResourceOptions? opts = null)
    public Server(String name, ServerArgs args)
    public Server(String name, ServerArgs args, CustomResourceOptions options)
    
    type: hcloud:Server
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args ServerArgs
    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 ServerArgs
    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 ServerArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ServerArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ServerArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Server 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 Server resource accepts the following input properties:

    ServerType string
    Name of the server type this server should be created with.
    AllowDeprecatedImages bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    Backups bool
    Enable or disable backups.
    Datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    DeleteProtection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    FirewallIds List<int>
    Firewall IDs the server should be attached to on creation.
    IgnoreRemoteFirewallIds bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    Image string
    Iso string
    ID or Name of an ISO image to mount.
    KeepDisk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    Labels Dictionary<string, object>
    User-defined labels (key-value pairs) should be created with.
    Location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    Name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    Networks List<Pulumi.HCloud.Inputs.ServerNetwork>
    Network the server should be attached to on creation. (Can be specified multiple times)
    PlacementGroupId int
    Placement Group ID the server added to on creation.
    PublicNets List<Pulumi.HCloud.Inputs.ServerPublicNet>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    RebuildProtection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    Rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    ShutdownBeforeDeletion bool
    Whether to try shutting the server down gracefully before deleting it.
    SshKeys List<string>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    UserData string
    Cloud-Init user data to use during server creation
    ServerType string
    Name of the server type this server should be created with.
    AllowDeprecatedImages bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    Backups bool
    Enable or disable backups.
    Datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    DeleteProtection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    FirewallIds []int
    Firewall IDs the server should be attached to on creation.
    IgnoreRemoteFirewallIds bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    Image string
    Iso string
    ID or Name of an ISO image to mount.
    KeepDisk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    Labels map[string]interface{}
    User-defined labels (key-value pairs) should be created with.
    Location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    Name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    Networks []ServerNetworkTypeArgs
    Network the server should be attached to on creation. (Can be specified multiple times)
    PlacementGroupId int
    Placement Group ID the server added to on creation.
    PublicNets []ServerPublicNetArgs
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    RebuildProtection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    Rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    ShutdownBeforeDeletion bool
    Whether to try shutting the server down gracefully before deleting it.
    SshKeys []string
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    UserData string
    Cloud-Init user data to use during server creation
    serverType String
    Name of the server type this server should be created with.
    allowDeprecatedImages Boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backups Boolean
    Enable or disable backups.
    datacenter String
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection Boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds List<Integer>
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds Boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image String
    iso String
    ID or Name of an ISO image to mount.
    keepDisk Boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Map<String,Object>
    User-defined labels (key-value pairs) should be created with.
    location String
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name String
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks List<ServerNetwork>
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId Integer
    Placement Group ID the server added to on creation.
    publicNets List<ServerPublicNet>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection Boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue String
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    shutdownBeforeDeletion Boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys List<String>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    userData String
    Cloud-Init user data to use during server creation
    serverType string
    Name of the server type this server should be created with.
    allowDeprecatedImages boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backups boolean
    Enable or disable backups.
    datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds number[]
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image string
    iso string
    ID or Name of an ISO image to mount.
    keepDisk boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels {[key: string]: any}
    User-defined labels (key-value pairs) should be created with.
    location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks ServerNetwork[]
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId number
    Placement Group ID the server added to on creation.
    publicNets ServerPublicNet[]
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    shutdownBeforeDeletion boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys string[]
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    userData string
    Cloud-Init user data to use during server creation
    server_type str
    Name of the server type this server should be created with.
    allow_deprecated_images bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backups bool
    Enable or disable backups.
    datacenter str
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    delete_protection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewall_ids Sequence[int]
    Firewall IDs the server should be attached to on creation.
    ignore_remote_firewall_ids bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image str
    iso str
    ID or Name of an ISO image to mount.
    keep_disk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Mapping[str, Any]
    User-defined labels (key-value pairs) should be created with.
    location str
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name str
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks Sequence[ServerNetworkArgs]
    Network the server should be attached to on creation. (Can be specified multiple times)
    placement_group_id int
    Placement Group ID the server added to on creation.
    public_nets Sequence[ServerPublicNetArgs]
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuild_protection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue str
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    shutdown_before_deletion bool
    Whether to try shutting the server down gracefully before deleting it.
    ssh_keys Sequence[str]
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    user_data str
    Cloud-Init user data to use during server creation
    serverType String
    Name of the server type this server should be created with.
    allowDeprecatedImages Boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backups Boolean
    Enable or disable backups.
    datacenter String
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection Boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds List<Number>
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds Boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image String
    iso String
    ID or Name of an ISO image to mount.
    keepDisk Boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Map<Any>
    User-defined labels (key-value pairs) should be created with.
    location String
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name String
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks List<Property Map>
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId Number
    Placement Group ID the server added to on creation.
    publicNets List<Property Map>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection Boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue String
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    shutdownBeforeDeletion Boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys List<String>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    userData String
    Cloud-Init user data to use during server creation

    Outputs

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

    BackupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    Id string
    The provider-assigned unique ID for this managed resource.
    Ipv4Address string
    (string) The IPv4 address.
    Ipv6Address string
    (string) The first IPv6 address of the assigned network.
    Ipv6Network string
    (string) The IPv6 network.
    PrimaryDiskSize int
    (int) The size of the primary disk in GB.
    Status string
    (string) The status of the server.
    BackupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    Id string
    The provider-assigned unique ID for this managed resource.
    Ipv4Address string
    (string) The IPv4 address.
    Ipv6Address string
    (string) The first IPv6 address of the assigned network.
    Ipv6Network string
    (string) The IPv6 network.
    PrimaryDiskSize int
    (int) The size of the primary disk in GB.
    Status string
    (string) The status of the server.
    backupWindow String
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    id String
    The provider-assigned unique ID for this managed resource.
    ipv4Address String
    (string) The IPv4 address.
    ipv6Address String
    (string) The first IPv6 address of the assigned network.
    ipv6Network String
    (string) The IPv6 network.
    primaryDiskSize Integer
    (int) The size of the primary disk in GB.
    status String
    (string) The status of the server.
    backupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    id string
    The provider-assigned unique ID for this managed resource.
    ipv4Address string
    (string) The IPv4 address.
    ipv6Address string
    (string) The first IPv6 address of the assigned network.
    ipv6Network string
    (string) The IPv6 network.
    primaryDiskSize number
    (int) The size of the primary disk in GB.
    status string
    (string) The status of the server.
    backup_window str
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    id str
    The provider-assigned unique ID for this managed resource.
    ipv4_address str
    (string) The IPv4 address.
    ipv6_address str
    (string) The first IPv6 address of the assigned network.
    ipv6_network str
    (string) The IPv6 network.
    primary_disk_size int
    (int) The size of the primary disk in GB.
    status str
    (string) The status of the server.
    backupWindow String
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    id String
    The provider-assigned unique ID for this managed resource.
    ipv4Address String
    (string) The IPv4 address.
    ipv6Address String
    (string) The first IPv6 address of the assigned network.
    ipv6Network String
    (string) The IPv6 network.
    primaryDiskSize Number
    (int) The size of the primary disk in GB.
    status String
    (string) The status of the server.

    Look up Existing Server Resource

    Get an existing Server 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?: ServerState, opts?: CustomResourceOptions): Server
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            allow_deprecated_images: Optional[bool] = None,
            backup_window: Optional[str] = None,
            backups: Optional[bool] = None,
            datacenter: Optional[str] = None,
            delete_protection: Optional[bool] = None,
            firewall_ids: Optional[Sequence[int]] = None,
            ignore_remote_firewall_ids: Optional[bool] = None,
            image: Optional[str] = None,
            ipv4_address: Optional[str] = None,
            ipv6_address: Optional[str] = None,
            ipv6_network: Optional[str] = None,
            iso: Optional[str] = None,
            keep_disk: Optional[bool] = None,
            labels: Optional[Mapping[str, Any]] = None,
            location: Optional[str] = None,
            name: Optional[str] = None,
            networks: Optional[Sequence[ServerNetworkArgs]] = None,
            placement_group_id: Optional[int] = None,
            primary_disk_size: Optional[int] = None,
            public_nets: Optional[Sequence[ServerPublicNetArgs]] = None,
            rebuild_protection: Optional[bool] = None,
            rescue: Optional[str] = None,
            server_type: Optional[str] = None,
            shutdown_before_deletion: Optional[bool] = None,
            ssh_keys: Optional[Sequence[str]] = None,
            status: Optional[str] = None,
            user_data: Optional[str] = None) -> Server
    func GetServer(ctx *Context, name string, id IDInput, state *ServerState, opts ...ResourceOption) (*Server, error)
    public static Server Get(string name, Input<string> id, ServerState? state, CustomResourceOptions? opts = null)
    public static Server get(String name, Output<String> id, ServerState 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:
    AllowDeprecatedImages bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    BackupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    Backups bool
    Enable or disable backups.
    Datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    DeleteProtection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    FirewallIds List<int>
    Firewall IDs the server should be attached to on creation.
    IgnoreRemoteFirewallIds bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    Image string
    Ipv4Address string
    (string) The IPv4 address.
    Ipv6Address string
    (string) The first IPv6 address of the assigned network.
    Ipv6Network string
    (string) The IPv6 network.
    Iso string
    ID or Name of an ISO image to mount.
    KeepDisk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    Labels Dictionary<string, object>
    User-defined labels (key-value pairs) should be created with.
    Location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    Name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    Networks List<Pulumi.HCloud.Inputs.ServerNetwork>
    Network the server should be attached to on creation. (Can be specified multiple times)
    PlacementGroupId int
    Placement Group ID the server added to on creation.
    PrimaryDiskSize int
    (int) The size of the primary disk in GB.
    PublicNets List<Pulumi.HCloud.Inputs.ServerPublicNet>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    RebuildProtection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    Rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    ServerType string
    Name of the server type this server should be created with.
    ShutdownBeforeDeletion bool
    Whether to try shutting the server down gracefully before deleting it.
    SshKeys List<string>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    Status string
    (string) The status of the server.
    UserData string
    Cloud-Init user data to use during server creation
    AllowDeprecatedImages bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    BackupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    Backups bool
    Enable or disable backups.
    Datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    DeleteProtection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    FirewallIds []int
    Firewall IDs the server should be attached to on creation.
    IgnoreRemoteFirewallIds bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    Image string
    Ipv4Address string
    (string) The IPv4 address.
    Ipv6Address string
    (string) The first IPv6 address of the assigned network.
    Ipv6Network string
    (string) The IPv6 network.
    Iso string
    ID or Name of an ISO image to mount.
    KeepDisk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    Labels map[string]interface{}
    User-defined labels (key-value pairs) should be created with.
    Location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    Name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    Networks []ServerNetworkTypeArgs
    Network the server should be attached to on creation. (Can be specified multiple times)
    PlacementGroupId int
    Placement Group ID the server added to on creation.
    PrimaryDiskSize int
    (int) The size of the primary disk in GB.
    PublicNets []ServerPublicNetArgs
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    RebuildProtection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    Rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    ServerType string
    Name of the server type this server should be created with.
    ShutdownBeforeDeletion bool
    Whether to try shutting the server down gracefully before deleting it.
    SshKeys []string
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    Status string
    (string) The status of the server.
    UserData string
    Cloud-Init user data to use during server creation
    allowDeprecatedImages Boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backupWindow String
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    backups Boolean
    Enable or disable backups.
    datacenter String
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection Boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds List<Integer>
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds Boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image String
    ipv4Address String
    (string) The IPv4 address.
    ipv6Address String
    (string) The first IPv6 address of the assigned network.
    ipv6Network String
    (string) The IPv6 network.
    iso String
    ID or Name of an ISO image to mount.
    keepDisk Boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Map<String,Object>
    User-defined labels (key-value pairs) should be created with.
    location String
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name String
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks List<ServerNetwork>
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId Integer
    Placement Group ID the server added to on creation.
    primaryDiskSize Integer
    (int) The size of the primary disk in GB.
    publicNets List<ServerPublicNet>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection Boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue String
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    serverType String
    Name of the server type this server should be created with.
    shutdownBeforeDeletion Boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys List<String>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    status String
    (string) The status of the server.
    userData String
    Cloud-Init user data to use during server creation
    allowDeprecatedImages boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backupWindow string
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    backups boolean
    Enable or disable backups.
    datacenter string
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds number[]
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image string
    ipv4Address string
    (string) The IPv4 address.
    ipv6Address string
    (string) The first IPv6 address of the assigned network.
    ipv6Network string
    (string) The IPv6 network.
    iso string
    ID or Name of an ISO image to mount.
    keepDisk boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels {[key: string]: any}
    User-defined labels (key-value pairs) should be created with.
    location string
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name string
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks ServerNetwork[]
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId number
    Placement Group ID the server added to on creation.
    primaryDiskSize number
    (int) The size of the primary disk in GB.
    publicNets ServerPublicNet[]
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue string
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    serverType string
    Name of the server type this server should be created with.
    shutdownBeforeDeletion boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys string[]
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    status string
    (string) The status of the server.
    userData string
    Cloud-Init user data to use during server creation
    allow_deprecated_images bool
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backup_window str
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    backups bool
    Enable or disable backups.
    datacenter str
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    delete_protection bool
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewall_ids Sequence[int]
    Firewall IDs the server should be attached to on creation.
    ignore_remote_firewall_ids bool
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image str
    ipv4_address str
    (string) The IPv4 address.
    ipv6_address str
    (string) The first IPv6 address of the assigned network.
    ipv6_network str
    (string) The IPv6 network.
    iso str
    ID or Name of an ISO image to mount.
    keep_disk bool
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Mapping[str, Any]
    User-defined labels (key-value pairs) should be created with.
    location str
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name str
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks Sequence[ServerNetworkArgs]
    Network the server should be attached to on creation. (Can be specified multiple times)
    placement_group_id int
    Placement Group ID the server added to on creation.
    primary_disk_size int
    (int) The size of the primary disk in GB.
    public_nets Sequence[ServerPublicNetArgs]
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuild_protection bool
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue str
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    server_type str
    Name of the server type this server should be created with.
    shutdown_before_deletion bool
    Whether to try shutting the server down gracefully before deleting it.
    ssh_keys Sequence[str]
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    status str
    (string) The status of the server.
    user_data str
    Cloud-Init user data to use during server creation
    allowDeprecatedImages Boolean
    Enable the use of deprecated images (default: false). Note Deprecated images will be removed after three months. Using them is then no longer possible.
    backupWindow String
    (string) The backup window of the server, if enabled.

    Deprecated:You should remove this property from your terraform configuration.

    backups Boolean
    Enable or disable backups.
    datacenter String
    The datacenter name to create the server in. nbg1-dc3, fsn1-dc14, hel1-dc2, ash-dc1 or hil-dc1
    deleteProtection Boolean
    Enable or disable delete protection (Needs to be the same as rebuild_protection). See "Delete Protection" in the Provider Docs for details.
    firewallIds List<Number>
    Firewall IDs the server should be attached to on creation.
    ignoreRemoteFirewallIds Boolean
    Ignores any updates to the firewall_ids argument which were received from the server. This should not be used in normal cases. See the documentation of the hcloud.FirewallAttachment resource for a reason to use this argument.
    image String
    ipv4Address String
    (string) The IPv4 address.
    ipv6Address String
    (string) The first IPv6 address of the assigned network.
    ipv6Network String
    (string) The IPv6 network.
    iso String
    ID or Name of an ISO image to mount.
    keepDisk Boolean
    If true, do not upgrade the disk. This allows downgrading the server type later.
    labels Map<Any>
    User-defined labels (key-value pairs) should be created with.
    location String
    The location name to create the server in. nbg1, fsn1, hel1, ash or hil
    name String
    Name of the server to create (must be unique per project and a valid hostname as per RFC 1123).
    networks List<Property Map>
    Network the server should be attached to on creation. (Can be specified multiple times)
    placementGroupId Number
    Placement Group ID the server added to on creation.
    primaryDiskSize Number
    (int) The size of the primary disk in GB.
    publicNets List<Property Map>
    In this block you can either enable / disable ipv4 and ipv6 or link existing primary IPs (checkout the examples). If this block is not defined, two primary (ipv4 & ipv6) ips getting auto generated.
    rebuildProtection Boolean
    Enable or disable rebuild protection (Needs to be the same as delete_protection).
    rescue String
    Enable and boot in to the specified rescue system. This enables simple installation of custom operating systems. linux64 or linux32
    serverType String
    Name of the server type this server should be created with.
    shutdownBeforeDeletion Boolean
    Whether to try shutting the server down gracefully before deleting it.
    sshKeys List<String>
    SSH key IDs or names which should be injected into the server at creation time. Once the server is created, you can not update the list of SSH Keys. If you do change this, you will be prompted to destroy and recreate the server. You can avoid this by setting lifecycle.ignore_changes to [ ssh_keys ].
    status String
    (string) The status of the server.
    userData String
    Cloud-Init user data to use during server creation

    Supporting Types

    ServerNetwork, ServerNetworkArgs

    NetworkId int
    ID of the network
    AliasIps List<string>
    Ip string
    Specify the IP the server should get in the network
    MacAddress string
    (Optional, string) The MAC address the private interface of the server has
    NetworkId int
    ID of the network
    AliasIps []string
    Ip string
    Specify the IP the server should get in the network
    MacAddress string
    (Optional, string) The MAC address the private interface of the server has
    networkId Integer
    ID of the network
    aliasIps List<String>
    ip String
    Specify the IP the server should get in the network
    macAddress String
    (Optional, string) The MAC address the private interface of the server has
    networkId number
    ID of the network
    aliasIps string[]
    ip string
    Specify the IP the server should get in the network
    macAddress string
    (Optional, string) The MAC address the private interface of the server has
    network_id int
    ID of the network
    alias_ips Sequence[str]
    ip str
    Specify the IP the server should get in the network
    mac_address str
    (Optional, string) The MAC address the private interface of the server has
    networkId Number
    ID of the network
    aliasIps List<String>
    ip String
    Specify the IP the server should get in the network
    macAddress String
    (Optional, string) The MAC address the private interface of the server has

    ServerPublicNet, ServerPublicNetArgs

    ipv4 Integer
    ipv4Enabled Boolean
    ipv6 Integer
    ipv6Enabled Boolean
    ipv4 number
    ipv4Enabled boolean
    ipv6 number
    ipv6Enabled boolean
    ipv4 Number
    ipv4Enabled Boolean
    ipv6 Number
    ipv6Enabled Boolean

    Import

    Servers can be imported using the server id:

    $ pulumi import hcloud:index/server:Server myserver id
    

    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