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 image2 = 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")
image2 = 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 = pulumi.output(hcloud.getFloatingIp({
    ipAddress: "1.2.3.4",
}, { async: true }));
const image2 = pulumi.output(hcloud.getFloatingIp({
    withSelector: "key=value",
}, { async: true }));
const main: hcloud.FloatingIpAssignment[] = [];
for (let i = 0; i < var_counter; i++) {
    main.push(new hcloud.FloatingIpAssignment(`main-${i}`, {
        floatingIpId: ip1.id!,
        serverId: hcloud_server_main.id,
    }));
}

Using GetFloatingIp

function getFloatingIp(args: GetFloatingIpArgs, opts?: InvokeOptions): Promise<GetFloatingIpResult>
function  get_floating_ip(id=None, ip_address=None, name=None, selector=None, with_selector=None, opts=None)
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
IpAddress string
Name string
Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
Id int
IpAddress string
Name string
Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
id number
ipAddress string
name string
selector string

Deprecated: Please use the with_selector property instead.

withSelector string
id float
ip_address str
name str
selector str

Deprecated: Please use the with_selector property instead.

with_selector str

GetFloatingIp Result

The following output properties are available:

Description string
HomeLocation string
IpAddress string
IpNetwork string
Labels Dictionary<string, object>
ServerId int
Type string
Id int
Name string
Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
Description string
HomeLocation string
IpAddress string
IpNetwork string
Labels map[string]interface{}
ServerId int
Type string
Id int
Name string
Selector string

Deprecated: Please use the with_selector property instead.

WithSelector string
description string
homeLocation string
ipAddress string
ipNetwork string
labels {[key: string]: any}
serverId number
type string
id number
name string
selector string

Deprecated: Please use the with_selector property instead.

withSelector string
description str
home_location str
ip_address str
ip_network str
labels Dict[str, Any]
server_id float
type str
id float
name str
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.