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

GetFloatingIp

Provides details about a Hetzner Cloud Floating IP.

This resource can be useful when you need to determine a Floating IP ID based on the IP address.

Example Usage

Additional Examples

using System.Collections.Generic;
using Pulumi;
using HCloud = Pulumi.HCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var ip1 = Output.Create(HCloud.GetFloatingIp.InvokeAsync(new HCloud.GetFloatingIpArgs
        {
            IpAddress = "1.2.3.4",
        }));
        var ip2 = Output.Create(HCloud.GetFloatingIp.InvokeAsync(new HCloud.GetFloatingIpArgs
        {
            WithSelector = "key=value",
        }));
        var main = new List<HCloud.FloatingIpAssignment>();
        for (var rangeIndex = 0; rangeIndex < @var.Counter; rangeIndex++)
        {
            var range = new { Value = rangeIndex };
            main.Add(new HCloud.FloatingIpAssignment($"main-{range.Value}", new HCloud.FloatingIpAssignmentArgs
            {
                FloatingIpId = ip1.Apply(ip1 => ip1.Id),
                ServerId = hcloud_server.Main.Id,
            }));
        }
    }

}
package main

import (
    "github.com/pulumi/pulumi-hcloud/sdk/go/hcloud"
    "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        opt0 := "1.2.3.4"
        ip1, err := hcloud.LookupFloatingIp(ctx, &hcloud.LookupFloatingIpArgs{
            IpAddress: &opt0,
        }, nil)
        if err != nil {
            return err
        }
        opt1 := "key=value"
        _, err = hcloud.LookupFloatingIp(ctx, &hcloud.LookupFloatingIpArgs{
            WithSelector: &opt1,
        }, nil)
        if err != nil {
            return err
        }
        var main []*hcloud.FloatingIpAssignment
        for key0, _ := range _var.Counter {
            __res, err := hcloud.NewFloatingIpAssignment(ctx, fmt.Sprintf("main-%v", key0), &hcloud.FloatingIpAssignmentArgs{
                FloatingIpId: pulumi.Int(ip1.Id),
                ServerId:     pulumi.Any(hcloud_server.Main.Id),
            })
            if err != nil {
                return err
            }
            main = append(main, __res)
        }
        return nil
    })
}
import pulumi
import pulumi_hcloud as hcloud

ip1 = hcloud.get_floating_ip(ip_address="1.2.3.4")
ip2 = hcloud.get_floating_ip(with_selector="key=value")
main = []
for range in [{"value": i} for i in range(0, var.counter)]:
    main.append(hcloud.FloatingIpAssignment(f"main-{range['value']}",
        floating_ip_id=ip1.id,
        server_id=hcloud_server["main"]["id"]))
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";

const ip1 = hcloud.getFloatingIp({
    ipAddress: "1.2.3.4",
});
const ip2 = hcloud.getFloatingIp({
    withSelector: "key=value",
});
const main: hcloud.FloatingIpAssignment[];
for (const range = {value: 0}; range.value < _var.counter; range.value++) {
    main.push(new hcloud.FloatingIpAssignment(`main-${range.value}`, {
        floatingIpId: ip1.then(ip1 => ip1.id),
        serverId: hcloud_server.main.id,
    }));
}

Using GetFloatingIp

function getFloatingIp(args: GetFloatingIpArgs, opts?: InvokeOptions): Promise<GetFloatingIpResult>
def get_floating_ip(id: Optional[int] = None, ip_address: Optional[str] = None, name: Optional[str] = None, selector: Optional[str] = None, with_selector: Optional[str] = None, opts: Optional[InvokeOptions] = None) -> GetFloatingIpResult
func LookupFloatingIp(ctx *Context, args *LookupFloatingIpArgs, opts ...InvokeOption) (*LookupFloatingIpResult, error)

Note: This function is named LookupFloatingIp in the Go SDK.

public static class GetFloatingIp {
    public static Task<GetFloatingIpResult> InvokeAsync(GetFloatingIpArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Id int

ID of the Floating IP.

IpAddress string

IP address of the Floating IP.

Name string

Name of the Floating IP.

Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string

Label selector

Id int

ID of the Floating IP.

IpAddress string

IP address of the Floating IP.

Name string

Name of the Floating IP.

Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string

Label selector

id number

ID of the Floating IP.

ipAddress string

IP address of the Floating IP.

name string

Name of the Floating IP.

selector string

Deprecated: Please use the with_selector property instead.

withSelector string

Label selector

id int

ID of the Floating IP.

ip_address str

IP address of the Floating IP.

name str

Name of the Floating IP.

selector str

Deprecated: Please use the with_selector property instead.

with_selector str

Label selector

GetFloatingIp Result

The following output properties are available:

Description string

(string) Description of the Floating IP.

HomeLocation string

(string) Home location.

Id int

(int) Unique ID of the Floating IP.

IpAddress string

(string) IP Address of the Floating IP.

IpNetwork string

(string) IPv6 subnet. (Only set if type is ipv6)

Labels Dictionary<string, object>

(map) User-defined labels (key-value pairs).

ServerId int

(int) Server to assign the Floating IP is assigned to.

Type string

(string) Type of the Floating IP.

Name string

(string) Name of the Floating IP.

Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
Description string

(string) Description of the Floating IP.

HomeLocation string

(string) Home location.

Id int

(int) Unique ID of the Floating IP.

IpAddress string

(string) IP Address of the Floating IP.

IpNetwork string

(string) IPv6 subnet. (Only set if type is ipv6)

Labels map[string]interface{}

(map) User-defined labels (key-value pairs).

ServerId int

(int) Server to assign the Floating IP is assigned to.

Type string

(string) Type of the Floating IP.

Name string

(string) Name of the Floating IP.

Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
description string

(string) Description of the Floating IP.

homeLocation string

(string) Home location.

id number

(int) Unique ID of the Floating IP.

ipAddress string

(string) IP Address of the Floating IP.

ipNetwork string

(string) IPv6 subnet. (Only set if type is ipv6)

labels {[key: string]: any}

(map) User-defined labels (key-value pairs).

serverId number

(int) Server to assign the Floating IP is assigned to.

type string

(string) Type of the Floating IP.

name string

(string) Name of the Floating IP.

selector string

Deprecated: Please use the with_selector property instead.

withSelector string
description str

(string) Description of the Floating IP.

home_location str

(string) Home location.

id int

(int) Unique ID of the Floating IP.

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, Any]

(map) User-defined labels (key-value pairs).

server_id int

(int) Server to assign the Floating IP is assigned to.

type str

(string) Type of the Floating IP.

name str

(string) Name of the Floating IP.

selector str

Deprecated: Please use the with_selector property instead.

with_selector str

Package Details

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