published on Wednesday, Apr 29, 2026 by Pulumi
published on Wednesday, Apr 29, 2026 by Pulumi
Provides a Hetzner Cloud Primary IP resource.
See the Primary IP API documentation for more details.
Deprecations
datacenter attribute
The datacenter attribute is deprecated, use the location attribute instead.
See our the API changelog for more details.
Please upgrade to
v1.58.0+of the provider to avoid issues once the Hetzner Cloud API no longer accepts and returns thedatacenterattribute. This version of the provider remains backward compatible by preserving thedatacentervalue in the state and by extracting thelocationname from thedatacenterattribute when communicating with the API.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as hcloud from "@pulumi/hcloud";
const main = new hcloud.PrimaryIp("main", {
name: "primary-ip",
location: "fsn1",
type: "ipv4",
autoDelete: false,
labels: {
key: "value",
},
});
// Link a server to a primary IP
const mainServer = new hcloud.Server("main", {
name: "server",
image: "ubuntu-24.04",
serverType: "cx23",
location: "fsn1",
publicNets: [{
ipv4: main.id,
}],
});
import pulumi
import pulumi_hcloud as hcloud
main = hcloud.PrimaryIp("main",
name="primary-ip",
location="fsn1",
type="ipv4",
auto_delete=False,
labels={
"key": "value",
})
# Link a server to a primary IP
main_server = hcloud.Server("main",
name="server",
image="ubuntu-24.04",
server_type="cx23",
location="fsn1",
public_nets=[{
"ipv4": 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 {
main, err := hcloud.NewPrimaryIp(ctx, "main", &hcloud.PrimaryIpArgs{
Name: pulumi.String("primary-ip"),
Location: pulumi.String("fsn1"),
Type: pulumi.String("ipv4"),
AutoDelete: pulumi.Bool(false),
Labels: pulumi.StringMap{
"key": pulumi.String("value"),
},
})
if err != nil {
return err
}
// Link a server to a primary IP
_, err = hcloud.NewServer(ctx, "main", &hcloud.ServerArgs{
Name: pulumi.String("server"),
Image: pulumi.String("ubuntu-24.04"),
ServerType: pulumi.String("cx23"),
Location: pulumi.String("fsn1"),
PublicNets: hcloud.ServerPublicNetArray{
&hcloud.ServerPublicNetArgs{
Ipv4: main.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 main = new HCloud.Index.PrimaryIp("main", new()
{
Name = "primary-ip",
Location = "fsn1",
Type = "ipv4",
AutoDelete = false,
Labels =
{
{ "key", "value" },
},
});
// Link a server to a primary IP
var mainServer = new HCloud.Index.Server("main", new()
{
Name = "server",
Image = "ubuntu-24.04",
ServerType = "cx23",
Location = "fsn1",
PublicNets = new[]
{
new HCloud.Inputs.ServerPublicNetArgs
{
Ipv4 = main.Id,
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.hcloud.PrimaryIp;
import com.pulumi.hcloud.PrimaryIpArgs;
import com.pulumi.hcloud.Server;
import com.pulumi.hcloud.ServerArgs;
import com.pulumi.hcloud.inputs.ServerPublicNetArgs;
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 main = new PrimaryIp("main", PrimaryIpArgs.builder()
.name("primary-ip")
.location("fsn1")
.type("ipv4")
.autoDelete(false)
.labels(Map.of("key", "value"))
.build());
// Link a server to a primary IP
var mainServer = new Server("mainServer", ServerArgs.builder()
.name("server")
.image("ubuntu-24.04")
.serverType("cx23")
.location("fsn1")
.publicNets(ServerPublicNetArgs.builder()
.ipv4(main.id())
.build())
.build());
}
}
resources:
main:
type: hcloud:PrimaryIp
properties:
name: primary-ip
location: fsn1
type: ipv4
autoDelete: false
labels:
key: value
# Link a server to a primary IP
mainServer:
type: hcloud:Server
name: main
properties:
name: server
image: ubuntu-24.04
serverType: cx23
location: fsn1
publicNets:
- ipv4: ${main.id}
Create PrimaryIp Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new PrimaryIp(name: string, args: PrimaryIpArgs, opts?: CustomResourceOptions);@overload
def PrimaryIp(resource_name: str,
args: PrimaryIpArgs,
opts: Optional[ResourceOptions] = None)
@overload
def PrimaryIp(resource_name: str,
opts: Optional[ResourceOptions] = None,
auto_delete: Optional[bool] = None,
type: Optional[str] = None,
assignee_id: Optional[int] = None,
assignee_type: Optional[str] = None,
datacenter: Optional[str] = None,
delete_protection: Optional[bool] = None,
labels: Optional[Mapping[str, str]] = None,
location: Optional[str] = None,
name: Optional[str] = None)func NewPrimaryIp(ctx *Context, name string, args PrimaryIpArgs, opts ...ResourceOption) (*PrimaryIp, error)public PrimaryIp(string name, PrimaryIpArgs args, CustomResourceOptions? opts = null)
public PrimaryIp(String name, PrimaryIpArgs args)
public PrimaryIp(String name, PrimaryIpArgs args, CustomResourceOptions options)
type: hcloud:PrimaryIp
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 PrimaryIpArgs
- 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 PrimaryIpArgs
- 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 PrimaryIpArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PrimaryIpArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args PrimaryIpArgs
- 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 primaryIpResource = new HCloud.PrimaryIp("primaryIpResource", new()
{
AutoDelete = false,
Type = "string",
AssigneeId = 0,
AssigneeType = "string",
DeleteProtection = false,
Labels =
{
{ "string", "string" },
},
Location = "string",
Name = "string",
});
example, err := hcloud.NewPrimaryIp(ctx, "primaryIpResource", &hcloud.PrimaryIpArgs{
AutoDelete: pulumi.Bool(false),
Type: pulumi.String("string"),
AssigneeId: pulumi.Int(0),
AssigneeType: pulumi.String("string"),
DeleteProtection: pulumi.Bool(false),
Labels: pulumi.StringMap{
"string": pulumi.String("string"),
},
Location: pulumi.String("string"),
Name: pulumi.String("string"),
})
var primaryIpResource = new PrimaryIp("primaryIpResource", PrimaryIpArgs.builder()
.autoDelete(false)
.type("string")
.assigneeId(0)
.assigneeType("string")
.deleteProtection(false)
.labels(Map.of("string", "string"))
.location("string")
.name("string")
.build());
primary_ip_resource = hcloud.PrimaryIp("primaryIpResource",
auto_delete=False,
type="string",
assignee_id=0,
assignee_type="string",
delete_protection=False,
labels={
"string": "string",
},
location="string",
name="string")
const primaryIpResource = new hcloud.PrimaryIp("primaryIpResource", {
autoDelete: false,
type: "string",
assigneeId: 0,
assigneeType: "string",
deleteProtection: false,
labels: {
string: "string",
},
location: "string",
name: "string",
});
type: hcloud:PrimaryIp
properties:
assigneeId: 0
assigneeType: string
autoDelete: false
deleteProtection: false
labels:
string: string
location: string
name: string
type: string
PrimaryIp 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 PrimaryIp resource accepts the following input properties:
- Auto
Delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - Type string
- Type of the Primary IP (
ipv4oripv6). - Assignee
Id int - ID of the resource the Primary IP should be assigned to.
- Assignee
Type string - Type of the resource the Primary IP should be assigned to.
- Datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- Delete
Protection bool - Whether delete protection is enabled.
- Labels Dictionary<string, string>
- User-defined labels (key-value pairs) for the resource.
- Location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Primary IP.
- Auto
Delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - Type string
- Type of the Primary IP (
ipv4oripv6). - Assignee
Id int - ID of the resource the Primary IP should be assigned to.
- Assignee
Type string - Type of the resource the Primary IP should be assigned to.
- Datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- Delete
Protection bool - Whether delete protection is enabled.
- Labels map[string]string
- User-defined labels (key-value pairs) for the resource.
- Location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Primary IP.
- auto
Delete Boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - type String
- Type of the Primary IP (
ipv4oripv6). - assignee
Id Integer - ID of the resource the Primary IP should be assigned to.
- assignee
Type String - Type of the resource the Primary IP should be assigned to.
- datacenter String
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection Boolean - Whether delete protection is enabled.
- labels Map<String,String>
- User-defined labels (key-value pairs) for the resource.
- location String
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name String
- Name of the Primary IP.
- auto
Delete boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - type string
- Type of the Primary IP (
ipv4oripv6). - assignee
Id number - ID of the resource the Primary IP should be assigned to.
- assignee
Type string - Type of the resource the Primary IP should be assigned to.
- datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection boolean - Whether delete protection is enabled.
- labels {[key: string]: string}
- User-defined labels (key-value pairs) for the resource.
- location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name string
- Name of the Primary IP.
- auto_
delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - type str
- Type of the Primary IP (
ipv4oripv6). - assignee_
id int - ID of the resource the Primary IP should be assigned to.
- assignee_
type str - Type of the resource the Primary IP should be assigned to.
- datacenter str
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete_
protection bool - Whether delete protection is enabled.
- labels Mapping[str, str]
- User-defined labels (key-value pairs) for the resource.
- location str
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name str
- Name of the Primary IP.
- auto
Delete Boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - type String
- Type of the Primary IP (
ipv4oripv6). - assignee
Id Number - ID of the resource the Primary IP should be assigned to.
- assignee
Type String - Type of the resource the Primary IP should be assigned to.
- datacenter String
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection Boolean - Whether delete protection is enabled.
- labels Map<String>
- User-defined labels (key-value pairs) for the resource.
- location String
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name String
- Name of the Primary IP.
Outputs
All input properties are implicitly available as output properties. Additionally, the PrimaryIp resource produces the following output properties:
- id str
- The provider-assigned unique ID for this managed resource.
- ip_
address str - IP address of the Primary IP.
- ip_
network str - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6.
Look up Existing PrimaryIp Resource
Get an existing PrimaryIp 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?: PrimaryIpState, opts?: CustomResourceOptions): PrimaryIp@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
assignee_id: Optional[int] = None,
assignee_type: Optional[str] = None,
auto_delete: Optional[bool] = None,
datacenter: Optional[str] = None,
delete_protection: Optional[bool] = None,
ip_address: Optional[str] = None,
ip_network: Optional[str] = None,
labels: Optional[Mapping[str, str]] = None,
location: Optional[str] = None,
name: Optional[str] = None,
type: Optional[str] = None) -> PrimaryIpfunc GetPrimaryIp(ctx *Context, name string, id IDInput, state *PrimaryIpState, opts ...ResourceOption) (*PrimaryIp, error)public static PrimaryIp Get(string name, Input<string> id, PrimaryIpState? state, CustomResourceOptions? opts = null)public static PrimaryIp get(String name, Output<String> id, PrimaryIpState state, CustomResourceOptions options)resources: _: type: hcloud:PrimaryIp get: id: ${id}- 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.
- Assignee
Id int - ID of the resource the Primary IP should be assigned to.
- Assignee
Type string - Type of the resource the Primary IP should be assigned to.
- Auto
Delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - Datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- Delete
Protection bool - Whether delete protection is enabled.
- Ip
Address string - IP address of the Primary IP.
- Ip
Network string - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - Labels Dictionary<string, string>
- User-defined labels (key-value pairs) for the resource.
- Location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Primary IP.
- Type string
- Type of the Primary IP (
ipv4oripv6).
- Assignee
Id int - ID of the resource the Primary IP should be assigned to.
- Assignee
Type string - Type of the resource the Primary IP should be assigned to.
- Auto
Delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - Datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- Delete
Protection bool - Whether delete protection is enabled.
- Ip
Address string - IP address of the Primary IP.
- Ip
Network string - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - Labels map[string]string
- User-defined labels (key-value pairs) for the resource.
- Location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- Name string
- Name of the Primary IP.
- Type string
- Type of the Primary IP (
ipv4oripv6).
- assignee
Id Integer - ID of the resource the Primary IP should be assigned to.
- assignee
Type String - Type of the resource the Primary IP should be assigned to.
- auto
Delete Boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - datacenter String
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection Boolean - Whether delete protection is enabled.
- ip
Address String - IP address of the Primary IP.
- ip
Network String - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - labels Map<String,String>
- User-defined labels (key-value pairs) for the resource.
- location String
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name String
- Name of the Primary IP.
- type String
- Type of the Primary IP (
ipv4oripv6).
- assignee
Id number - ID of the resource the Primary IP should be assigned to.
- assignee
Type string - Type of the resource the Primary IP should be assigned to.
- auto
Delete boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - datacenter string
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection boolean - Whether delete protection is enabled.
- ip
Address string - IP address of the Primary IP.
- ip
Network string - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - labels {[key: string]: string}
- User-defined labels (key-value pairs) for the resource.
- location string
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name string
- Name of the Primary IP.
- type string
- Type of the Primary IP (
ipv4oripv6).
- assignee_
id int - ID of the resource the Primary IP should be assigned to.
- assignee_
type str - Type of the resource the Primary IP should be assigned to.
- auto_
delete bool - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - datacenter str
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete_
protection bool - Whether delete protection is enabled.
- ip_
address str - IP address of the Primary IP.
- ip_
network str - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - labels Mapping[str, str]
- User-defined labels (key-value pairs) for the resource.
- location str
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name str
- Name of the Primary IP.
- type str
- Type of the Primary IP (
ipv4oripv6).
- assignee
Id Number - ID of the resource the Primary IP should be assigned to.
- assignee
Type String - Type of the resource the Primary IP should be assigned to.
- auto
Delete Boolean - Whether auto delete is enabled. Setting
autoDeletetofalseis recommended, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the terraform state. - datacenter String
- Name of the Datacenter for the Primary IP. See the Hetzner Docs for more details about datacenters.
- delete
Protection Boolean - Whether delete protection is enabled.
- ip
Address String - IP address of the Primary IP.
- ip
Network String - IP network of the Primary IP for IPv6 addresses. Only set if
typeisipv6. - labels Map<String>
- User-defined labels (key-value pairs) for the resource.
- location String
- Name of the Location for the Primary IP. See the Hetzner Docs for more details about locations.
- name String
- Name of the Primary IP.
- type String
- Type of the Primary IP (
ipv4oripv6).
Import
The pulumi import command can be used, for example:
$ pulumi import hcloud:index/primaryIp:PrimaryIp example "$PRIMARY_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
hcloudTerraform Provider.
published on Wednesday, Apr 29, 2026 by Pulumi
