hcloud.FloatingIpAssignment
Explore with Pulumi AI
Provides a Hetzner Cloud Floating IP Assignment to assign a Floating IP to a Hetzner Cloud Server. Deleting a Floating IP Assignment will unassign the Floating IP from the Server.
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",
datacenter: "fsn1-dc8",
});
const master = new hcloud.FloatingIp("master", {
type: "ipv4",
homeLocation: "nbg1",
});
const main = new hcloud.FloatingIpAssignment("main", {
floatingIpId: master.id,
serverId: node1.id,
});
import pulumi
import pulumi_hcloud as hcloud
node1 = hcloud.Server("node1",
name="node1",
image="debian-11",
server_type="cx22",
datacenter="fsn1-dc8")
master = hcloud.FloatingIp("master",
type="ipv4",
home_location="nbg1")
main = hcloud.FloatingIpAssignment("main",
floating_ip_id=master.id,
server_id=node1.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 {
node1, err := hcloud.NewServer(ctx, "node1", &hcloud.ServerArgs{
Name: pulumi.String("node1"),
Image: pulumi.String("debian-11"),
ServerType: pulumi.String("cx22"),
Datacenter: pulumi.String("fsn1-dc8"),
})
if err != nil {
return err
}
master, err := hcloud.NewFloatingIp(ctx, "master", &hcloud.FloatingIpArgs{
Type: pulumi.String("ipv4"),
HomeLocation: pulumi.String("nbg1"),
})
if err != nil {
return err
}
_, err = hcloud.NewFloatingIpAssignment(ctx, "main", &hcloud.FloatingIpAssignmentArgs{
FloatingIpId: master.ID(),
ServerId: node1.ID(),
})
if err != nil {
return err
}
return nil
})
}
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",
Datacenter = "fsn1-dc8",
});
var master = new HCloud.FloatingIp("master", new()
{
Type = "ipv4",
HomeLocation = "nbg1",
});
var main = new HCloud.FloatingIpAssignment("main", new()
{
FloatingIpId = master.Id,
ServerId = node1.Id,
});
});
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 com.pulumi.hcloud.FloatingIpAssignment;
import com.pulumi.hcloud.FloatingIpAssignmentArgs;
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")
.datacenter("fsn1-dc8")
.build());
var master = new FloatingIp("master", FloatingIpArgs.builder()
.type("ipv4")
.homeLocation("nbg1")
.build());
var main = new FloatingIpAssignment("main", FloatingIpAssignmentArgs.builder()
.floatingIpId(master.id())
.serverId(node1.id())
.build());
}
}
resources:
main:
type: hcloud:FloatingIpAssignment
properties:
floatingIpId: ${master.id}
serverId: ${node1.id}
node1:
type: hcloud:Server
properties:
name: node1
image: debian-11
serverType: cx22
datacenter: fsn1-dc8
master:
type: hcloud:FloatingIp
properties:
type: ipv4
homeLocation: nbg1
Create FloatingIpAssignment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new FloatingIpAssignment(name: string, args: FloatingIpAssignmentArgs, opts?: CustomResourceOptions);
@overload
def FloatingIpAssignment(resource_name: str,
args: FloatingIpAssignmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def FloatingIpAssignment(resource_name: str,
opts: Optional[ResourceOptions] = None,
floating_ip_id: Optional[int] = None,
server_id: Optional[int] = None)
func NewFloatingIpAssignment(ctx *Context, name string, args FloatingIpAssignmentArgs, opts ...ResourceOption) (*FloatingIpAssignment, error)
public FloatingIpAssignment(string name, FloatingIpAssignmentArgs args, CustomResourceOptions? opts = null)
public FloatingIpAssignment(String name, FloatingIpAssignmentArgs args)
public FloatingIpAssignment(String name, FloatingIpAssignmentArgs args, CustomResourceOptions options)
type: hcloud:FloatingIpAssignment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args FloatingIpAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args FloatingIpAssignmentArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args FloatingIpAssignmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args FloatingIpAssignmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args FloatingIpAssignmentArgs
- 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 floatingIpAssignmentResource = new HCloud.FloatingIpAssignment("floatingIpAssignmentResource", new()
{
FloatingIpId = 0,
ServerId = 0,
});
example, err := hcloud.NewFloatingIpAssignment(ctx, "floatingIpAssignmentResource", &hcloud.FloatingIpAssignmentArgs{
FloatingIpId: pulumi.Int(0),
ServerId: pulumi.Int(0),
})
var floatingIpAssignmentResource = new FloatingIpAssignment("floatingIpAssignmentResource", FloatingIpAssignmentArgs.builder()
.floatingIpId(0)
.serverId(0)
.build());
floating_ip_assignment_resource = hcloud.FloatingIpAssignment("floatingIpAssignmentResource",
floating_ip_id=0,
server_id=0)
const floatingIpAssignmentResource = new hcloud.FloatingIpAssignment("floatingIpAssignmentResource", {
floatingIpId: 0,
serverId: 0,
});
type: hcloud:FloatingIpAssignment
properties:
floatingIpId: 0
serverId: 0
FloatingIpAssignment 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 FloatingIpAssignment resource accepts the following input properties:
- Floating
Ip intId - ID of the Floating IP.
- Server
Id int - Server to assign the Floating IP to.
- Floating
Ip intId - ID of the Floating IP.
- Server
Id int - Server to assign the Floating IP to.
- floating
Ip IntegerId - ID of the Floating IP.
- server
Id Integer - Server to assign the Floating IP to.
- floating
Ip numberId - ID of the Floating IP.
- server
Id number - Server to assign the Floating IP to.
- floating_
ip_ intid - ID of the Floating IP.
- server_
id int - Server to assign the Floating IP to.
- floating
Ip NumberId - ID of the Floating IP.
- server
Id Number - Server to assign the Floating IP to.
Outputs
All input properties are implicitly available as output properties. Additionally, the FloatingIpAssignment resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing FloatingIpAssignment Resource
Get an existing FloatingIpAssignment 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?: FloatingIpAssignmentState, opts?: CustomResourceOptions): FloatingIpAssignment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
floating_ip_id: Optional[int] = None,
server_id: Optional[int] = None) -> FloatingIpAssignment
func GetFloatingIpAssignment(ctx *Context, name string, id IDInput, state *FloatingIpAssignmentState, opts ...ResourceOption) (*FloatingIpAssignment, error)
public static FloatingIpAssignment Get(string name, Input<string> id, FloatingIpAssignmentState? state, CustomResourceOptions? opts = null)
public static FloatingIpAssignment get(String name, Output<String> id, FloatingIpAssignmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Floating
Ip intId - ID of the Floating IP.
- Server
Id int - Server to assign the Floating IP to.
- Floating
Ip intId - ID of the Floating IP.
- Server
Id int - Server to assign the Floating IP to.
- floating
Ip IntegerId - ID of the Floating IP.
- server
Id Integer - Server to assign the Floating IP to.
- floating
Ip numberId - ID of the Floating IP.
- server
Id number - Server to assign the Floating IP to.
- floating_
ip_ intid - ID of the Floating IP.
- server_
id int - Server to assign the Floating IP to.
- floating
Ip NumberId - ID of the Floating IP.
- server
Id Number - Server to assign the Floating IP to.
Import
Floating IP Assignments can be imported using the floating_ip_id
:
$ pulumi import hcloud:index/floatingIpAssignment:FloatingIpAssignment example "$FLOATING_IP_ID"
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.