Hetzner Cloud

v1.10.1 published on Wednesday, Aug 3, 2022 by Pulumi

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/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		ip1, err := hcloud.LookupFloatingIp(ctx, &GetFloatingIpArgs{
			IpAddress: pulumi.StringRef("1.2.3.4"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = hcloud.LookupFloatingIp(ctx, &GetFloatingIpArgs{
			WithSelector: pulumi.StringRef("key=value"),
		}, 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
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;
import com.pulumi.codegen.internal.KeyedValue;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var ip1 = Output.of(HcloudFunctions.getFloatingIp(GetFloatingIpArgs.builder()
            .ipAddress("1.2.3.4")
            .build()));

        final var ip2 = Output.of(HcloudFunctions.getFloatingIp(GetFloatingIpArgs.builder()
            .withSelector("key=value")
            .build()));

        for (var i = 0; i < var_.counter(); i++) {
            new FloatingIpAssignment("main-" + i, FloatingIpAssignmentArgs.builder()            
                .floatingIpId(ip1.apply(getFloatingIpResult -> getFloatingIpResult.id()))
                .serverId(hcloud_server.main().id())
                .build());

        
}
    }
}
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,
    }));
}
resources:
  main:
    type: hcloud:FloatingIpAssignment
    properties:
      floatingIpId: ${ip1.id}
      serverId: ${hcloud_server.main.id}
    options: {}
variables:
  ip1:
    Fn::Invoke:
      Function: hcloud:getFloatingIp
      Arguments:
        ipAddress: 1.2.3.4
  ip2:
    Fn::Invoke:
      Function: hcloud:getFloatingIp
      Arguments:
        withSelector: key=value

Using getFloatingIp

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getFloatingIp(args: GetFloatingIpArgs, opts?: InvokeOptions): Promise<GetFloatingIpResult>
function getFloatingIpOutput(args: GetFloatingIpOutputArgs, opts?: InvokeOptions): Output<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
def get_floating_ip_output(id: Optional[pulumi.Input[int]] = None,
                    ip_address: Optional[pulumi.Input[str]] = None,
                    name: Optional[pulumi.Input[str]] = None,
                    selector: Optional[pulumi.Input[str]] = None,
                    with_selector: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetFloatingIpResult]
func LookupFloatingIp(ctx *Context, args *LookupFloatingIpArgs, opts ...InvokeOption) (*LookupFloatingIpResult, error)
func LookupFloatingIpOutput(ctx *Context, args *LookupFloatingIpOutputArgs, opts ...InvokeOption) LookupFloatingIpResultOutput

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

public static class GetFloatingIp 
{
    public static Task<GetFloatingIpResult> InvokeAsync(GetFloatingIpArgs args, InvokeOptions? opts = null)
    public static Output<GetFloatingIpResult> Invoke(GetFloatingIpInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetFloatingIpResult> getFloatingIp(GetFloatingIpArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: hcloud:index/getFloatingIp:getFloatingIp
  arguments:
    # arguments dictionary

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 Integer

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

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

getFloatingIp Result

The following output properties are available:

DeleteProtection bool

(boolean) Whether delete protection is enabled.

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
DeleteProtection bool

(boolean) Whether delete protection is enabled.

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
deleteProtection Boolean

(boolean) Whether delete protection is enabled.

description String

(string) Description of the Floating IP.

homeLocation String

(string) Home location.

id Integer

(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,Object>

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

serverId Integer

(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
deleteProtection boolean

(boolean) Whether delete protection is enabled.

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
delete_protection bool

(boolean) Whether delete protection is enabled.

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
deleteProtection Boolean

(boolean) Whether delete protection is enabled.

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 Map<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

Package Details

Repository
https://github.com/pulumi/pulumi-hcloud
License
Apache-2.0
Notes

This Pulumi package is based on the hcloud Terraform Provider.