1. Packages
  2. Hcloud Provider
  3. API Docs
  4. FloatingIp
Hetzner Cloud v1.22.0 published on Wednesday, Feb 26, 2025 by Pulumi

hcloud.FloatingIp

Explore with Pulumi AI

Provides a Hetzner Cloud Floating IP to represent a publicly-accessible static IP address that can be mapped to one of your servers.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const node1 = new hcloud.Server("node1", {
    name: "node1",
    image: "debian-11",
    serverType: "cx22",
});
const master = new hcloud.FloatingIp("master", {
    type: "ipv4",
    serverId: node1.id,
});
Copy
import pulumi
import pulumi_hcloud as hcloud

node1 = hcloud.Server("node1",
    name="node1",
    image="debian-11",
    server_type="cx22")
master = hcloud.FloatingIp("master",
    type="ipv4",
    server_id=node1.id)
Copy
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 {
		node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
			Name:       pulumi.String("node1"),
			Image:      pulumi.String("debian-11"),
			ServerType: pulumi.String("cx22"),
		})
		if err != nil {
			return err
		}
		_, err = hcloud.NewFloatingIp(ctx, "master", &hcloud.FloatingIpArgs{
			Type:     pulumi.String("ipv4"),
			ServerId: node1.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using HCloud = Pulumi.HCloud;

return await Deployment.RunAsync(() => 
{
    var node1 = new HCloud.Server("node1", new()
    {
        Name = "node1",
        Image = "debian-11",
        ServerType = "cx22",
    });

    var master = new HCloud.FloatingIp("master", new()
    {
        Type = "ipv4",
        ServerId = node1.Id,
    });

});
Copy
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.FloatingIp;
import com.pulumi.hcloud.FloatingIpArgs;
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()
            .name("node1")
            .image("debian-11")
            .serverType("cx22")
            .build());

        var master = new FloatingIp("master", FloatingIpArgs.builder()
            .type("ipv4")
            .serverId(node1.id())
            .build());

    }
}
Copy
resources:
  node1:
    type: hcloud:Server
    properties:
      name: node1
      image: debian-11
      serverType: cx22
  master:
    type: hcloud:FloatingIp
    properties:
      type: ipv4
      serverId: ${node1.id}
Copy

Create FloatingIp Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new FloatingIp(name: string, args: FloatingIpArgs, opts?: CustomResourceOptions);
@overload
def FloatingIp(resource_name: str,
               args: FloatingIpArgs,
               opts: Optional[ResourceOptions] = None)

@overload
def FloatingIp(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               type: Optional[str] = None,
               delete_protection: Optional[bool] = None,
               description: Optional[str] = None,
               home_location: Optional[str] = None,
               labels: Optional[Mapping[str, str]] = None,
               name: Optional[str] = None,
               server_id: Optional[int] = None)
func NewFloatingIp(ctx *Context, name string, args FloatingIpArgs, opts ...ResourceOption) (*FloatingIp, error)
public FloatingIp(string name, FloatingIpArgs args, CustomResourceOptions? opts = null)
public FloatingIp(String name, FloatingIpArgs args)
public FloatingIp(String name, FloatingIpArgs args, CustomResourceOptions options)
type: hcloud:FloatingIp
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. FloatingIpArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. FloatingIpArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. FloatingIpArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. FloatingIpArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. FloatingIpArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var floatingIpResource = new HCloud.FloatingIp("floatingIpResource", new()
{
    Type = "string",
    DeleteProtection = false,
    Description = "string",
    HomeLocation = "string",
    Labels = 
    {
        { "string", "string" },
    },
    Name = "string",
    ServerId = 0,
});
Copy
example, err := hcloud.NewFloatingIp(ctx, "floatingIpResource", &hcloud.FloatingIpArgs{
	Type:             pulumi.String("string"),
	DeleteProtection: pulumi.Bool(false),
	Description:      pulumi.String("string"),
	HomeLocation:     pulumi.String("string"),
	Labels: pulumi.StringMap{
		"string": pulumi.String("string"),
	},
	Name:     pulumi.String("string"),
	ServerId: pulumi.Int(0),
})
Copy
var floatingIpResource = new FloatingIp("floatingIpResource", FloatingIpArgs.builder()
    .type("string")
    .deleteProtection(false)
    .description("string")
    .homeLocation("string")
    .labels(Map.of("string", "string"))
    .name("string")
    .serverId(0)
    .build());
Copy
floating_ip_resource = hcloud.FloatingIp("floatingIpResource",
    type="string",
    delete_protection=False,
    description="string",
    home_location="string",
    labels={
        "string": "string",
    },
    name="string",
    server_id=0)
Copy
const floatingIpResource = new hcloud.FloatingIp("floatingIpResource", {
    type: "string",
    deleteProtection: false,
    description: "string",
    homeLocation: "string",
    labels: {
        string: "string",
    },
    name: "string",
    serverId: 0,
});
Copy
type: hcloud:FloatingIp
properties:
    deleteProtection: false
    description: string
    homeLocation: string
    labels:
        string: string
    name: string
    serverId: 0
    type: string
Copy

FloatingIp Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The FloatingIp resource accepts the following input properties:

Type
This property is required.
Changes to this property will trigger replacement.
string
Type of the Floating IP. ipv4 ipv6
DeleteProtection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Description string
Description of the Floating IP.
HomeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
Labels Dictionary<string, string>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Floating IP.
ServerId int
Server to assign the Floating IP to. Optional if home_location argument is passed.
Type
This property is required.
Changes to this property will trigger replacement.
string
Type of the Floating IP. ipv4 ipv6
DeleteProtection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Description string
Description of the Floating IP.
HomeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
Labels map[string]string
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Floating IP.
ServerId int
Server to assign the Floating IP to. Optional if home_location argument is passed.
type
This property is required.
Changes to this property will trigger replacement.
String
Type of the Floating IP. ipv4 ipv6
deleteProtection Boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description String
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. String
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
labels Map<String,String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Floating IP.
serverId Integer
Server to assign the Floating IP to. Optional if home_location argument is passed.
type
This property is required.
Changes to this property will trigger replacement.
string
Type of the Floating IP. ipv4 ipv6
deleteProtection boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description string
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
labels {[key: string]: string}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Floating IP.
serverId number
Server to assign the Floating IP to. Optional if home_location argument is passed.
type
This property is required.
Changes to this property will trigger replacement.
str
Type of the Floating IP. ipv4 ipv6
delete_protection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description str
Description of the Floating IP.
home_location Changes to this property will trigger replacement. str
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
labels Mapping[str, str]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Floating IP.
server_id int
Server to assign the Floating IP to. Optional if home_location argument is passed.
type
This property is required.
Changes to this property will trigger replacement.
String
Type of the Floating IP. ipv4 ipv6
deleteProtection Boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description String
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. String
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
labels Map<String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Floating IP.
serverId Number
Server to assign the Floating IP to. Optional if home_location argument is passed.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
(string) IP Address of the Floating IP.
IpNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
(string) IP Address of the Floating IP.
IpNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
id String
The provider-assigned unique ID for this managed resource.
ipAddress String
(string) IP Address of the Floating IP.
ipNetwork String
(string) IPv6 subnet. (Only set if type is ipv6)
id string
The provider-assigned unique ID for this managed resource.
ipAddress string
(string) IP Address of the Floating IP.
ipNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
id str
The provider-assigned unique ID for this managed resource.
ip_address str
(string) IP Address of the Floating IP.
ip_network str
(string) IPv6 subnet. (Only set if type is ipv6)
id String
The provider-assigned unique ID for this managed resource.
ipAddress String
(string) IP Address of the Floating IP.
ipNetwork String
(string) IPv6 subnet. (Only set if type is ipv6)

Look up Existing FloatingIp Resource

Get an existing FloatingIp 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?: FloatingIpState, opts?: CustomResourceOptions): FloatingIp
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        delete_protection: Optional[bool] = None,
        description: Optional[str] = None,
        home_location: Optional[str] = None,
        ip_address: Optional[str] = None,
        ip_network: Optional[str] = None,
        labels: Optional[Mapping[str, str]] = None,
        name: Optional[str] = None,
        server_id: Optional[int] = None,
        type: Optional[str] = None) -> FloatingIp
func GetFloatingIp(ctx *Context, name string, id IDInput, state *FloatingIpState, opts ...ResourceOption) (*FloatingIp, error)
public static FloatingIp Get(string name, Input<string> id, FloatingIpState? state, CustomResourceOptions? opts = null)
public static FloatingIp get(String name, Output<String> id, FloatingIpState state, CustomResourceOptions options)
resources:  _:    type: hcloud:FloatingIp    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
DeleteProtection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Description string
Description of the Floating IP.
HomeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
IpAddress string
(string) IP Address of the Floating IP.
IpNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
Labels Dictionary<string, string>
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Floating IP.
ServerId int
Server to assign the Floating IP to. Optional if home_location argument is passed.
Type Changes to this property will trigger replacement. string
Type of the Floating IP. ipv4 ipv6
DeleteProtection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
Description string
Description of the Floating IP.
HomeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
IpAddress string
(string) IP Address of the Floating IP.
IpNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
Labels map[string]string
User-defined labels (key-value pairs) should be created with.
Name string
Name of the Floating IP.
ServerId int
Server to assign the Floating IP to. Optional if home_location argument is passed.
Type Changes to this property will trigger replacement. string
Type of the Floating IP. ipv4 ipv6
deleteProtection Boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description String
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. String
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
ipAddress String
(string) IP Address of the Floating IP.
ipNetwork String
(string) IPv6 subnet. (Only set if type is ipv6)
labels Map<String,String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Floating IP.
serverId Integer
Server to assign the Floating IP to. Optional if home_location argument is passed.
type Changes to this property will trigger replacement. String
Type of the Floating IP. ipv4 ipv6
deleteProtection boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description string
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. string
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
ipAddress string
(string) IP Address of the Floating IP.
ipNetwork string
(string) IPv6 subnet. (Only set if type is ipv6)
labels {[key: string]: string}
User-defined labels (key-value pairs) should be created with.
name string
Name of the Floating IP.
serverId number
Server to assign the Floating IP to. Optional if home_location argument is passed.
type Changes to this property will trigger replacement. string
Type of the Floating IP. ipv4 ipv6
delete_protection bool
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description str
Description of the Floating IP.
home_location Changes to this property will trigger replacement. str
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
ip_address str
(string) IP Address of the Floating IP.
ip_network str
(string) IPv6 subnet. (Only set if type is ipv6)
labels Mapping[str, str]
User-defined labels (key-value pairs) should be created with.
name str
Name of the Floating IP.
server_id int
Server to assign the Floating IP to. Optional if home_location argument is passed.
type Changes to this property will trigger replacement. str
Type of the Floating IP. ipv4 ipv6
deleteProtection Boolean
Enable or disable delete protection. See "Delete Protection" in the Provider Docs for details.
description String
Description of the Floating IP.
homeLocation Changes to this property will trigger replacement. String
Name of home location (routing is optimized for that location). Optional if server_id argument is passed.
ipAddress String
(string) IP Address of the Floating IP.
ipNetwork String
(string) IPv6 subnet. (Only set if type is ipv6)
labels Map<String>
User-defined labels (key-value pairs) should be created with.
name String
Name of the Floating IP.
serverId Number
Server to assign the Floating IP to. Optional if home_location argument is passed.
type Changes to this property will trigger replacement. String
Type of the Floating IP. ipv4 ipv6

Import

Floating IPs can be imported using its id:

$ pulumi import hcloud:index/floatingIp:FloatingIp example "$FLOATING_IP_ID"
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Hetzner Cloud pulumi/pulumi-hcloud
License
Apache-2.0
Notes
This Pulumi package is based on the hcloud Terraform Provider.