1. Packages
  2. Hetzner Cloud
  3. API Docs
  4. getFloatingIp
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

hcloud.getFloatingIp

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.18.1 published on Tuesday, Apr 9, 2024 by Pulumi

    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

    Data Source: hcloud.FloatingIp

    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.

    Additional Examples

    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,
        }));
    }
    
    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"]))
    
    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, &hcloud.LookupFloatingIpArgs{
    			IpAddress: pulumi.StringRef("1.2.3.4"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.LookupFloatingIp(ctx, &hcloud.LookupFloatingIpArgs{
    			WithSelector: pulumi.StringRef("key=value"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		var main []*hcloud.FloatingIpAssignment
    		for index := 0; index < _var.Counter; index++ {
    			key0 := index
    			_ := index
    			__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
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var ip1 = HCloud.GetFloatingIp.Invoke(new()
        {
            IpAddress = "1.2.3.4",
        });
    
        var ip2 = HCloud.GetFloatingIp.Invoke(new()
        {
            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()
            {
                FloatingIpId = ip1.Apply(getFloatingIpResult => getFloatingIpResult.Id),
                ServerId = hcloud_server.Main.Id,
            }));
        }
    });
    
    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.GetFloatingIpArgs;
    import com.pulumi.hcloud.FloatingIpAssignment;
    import com.pulumi.hcloud.FloatingIpAssignmentArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    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 ip1 = HcloudFunctions.getFloatingIp(GetFloatingIpArgs.builder()
                .ipAddress("1.2.3.4")
                .build());
    
            final var ip2 = HcloudFunctions.getFloatingIp(GetFloatingIpArgs.builder()
                .withSelector("key=value")
                .build());
    
            for (var i = 0; i < var_.counter(); i++) {
                new FloatingIpAssignment("main-" + i, FloatingIpAssignmentArgs.builder()            
                    .floatingIpId(ip1.applyValue(getFloatingIpResult -> getFloatingIpResult.id()))
                    .serverId(hcloud_server.main().id())
                    .build());
    
            
    }
        }
    }
    
    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
    (bool) 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
    (bool) 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
    (bool) 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
    (bool) 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
    (bool) 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
    (bool) 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
    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.1 published on Tuesday, Apr 9, 2024 by Pulumi