1. Packages
  2. Hetzner Cloud
  3. API Docs
  4. PrimaryIp
Hetzner Cloud v1.14.1 published on Monday, Aug 14, 2023 by Pulumi

hcloud.PrimaryIp

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.14.1 published on Monday, Aug 14, 2023 by Pulumi

    Provides a Hetzner Cloud Primary IP to represent a publicly-accessible static IP address that can be mapped to one of your servers.

    If a server is getting created, it has to have a primary ip. If a server is getting created without defining primary ips, two of them (one ipv4 and one ipv6) getting created & attached. Currently, Primary IPs can be only attached to servers.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using HCloud = Pulumi.HCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var main = new HCloud.PrimaryIp("main", new()
        {
            Datacenter = "fsn1-dc14",
            Type = "ipv4",
            AssigneeType = "server",
            AutoDelete = true,
            Labels = 
            {
                { "hallo", "welt" },
            },
        });
    
        // Link a server to a primary IP
        var serverTest = new HCloud.Server("serverTest", new()
        {
            Image = "ubuntu-20.04",
            ServerType = "cx11",
            Datacenter = "fsn1-dc14",
            Labels = 
            {
                { "test", "tessst1" },
            },
            PublicNets = new[]
            {
                new HCloud.Inputs.ServerPublicNetArgs
                {
                    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{
    			Datacenter:   pulumi.String("fsn1-dc14"),
    			Type:         pulumi.String("ipv4"),
    			AssigneeType: pulumi.String("server"),
    			AutoDelete:   pulumi.Bool(true),
    			Labels: pulumi.AnyMap{
    				"hallo": pulumi.Any("welt"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = hcloud.NewServer(ctx, "serverTest", &hcloud.ServerArgs{
    			Image:      pulumi.String("ubuntu-20.04"),
    			ServerType: pulumi.String("cx11"),
    			Datacenter: pulumi.String("fsn1-dc14"),
    			Labels: pulumi.AnyMap{
    				"test": pulumi.Any("tessst1"),
    			},
    			PublicNets: hcloud.ServerPublicNetArray{
    				&hcloud.ServerPublicNetArgs{
    					Ipv4: main.ID(),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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()        
                .datacenter("fsn1-dc14")
                .type("ipv4")
                .assigneeType("server")
                .autoDelete(true)
                .labels(Map.of("hallo", "welt"))
                .build());
    
            var serverTest = new Server("serverTest", ServerArgs.builder()        
                .image("ubuntu-20.04")
                .serverType("cx11")
                .datacenter("fsn1-dc14")
                .labels(Map.of("test", "tessst1"))
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4(main.id())
                    .build())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    main = hcloud.PrimaryIp("main",
        datacenter="fsn1-dc14",
        type="ipv4",
        assignee_type="server",
        auto_delete=True,
        labels={
            "hallo": "welt",
        })
    # Link a server to a primary IP
    server_test = hcloud.Server("serverTest",
        image="ubuntu-20.04",
        server_type="cx11",
        datacenter="fsn1-dc14",
        labels={
            "test": "tessst1",
        },
        public_nets=[hcloud.ServerPublicNetArgs(
            ipv4=main.id,
        )])
    
    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const main = new hcloud.PrimaryIp("main", {
        datacenter: "fsn1-dc14",
        type: "ipv4",
        assigneeType: "server",
        autoDelete: true,
        labels: {
            hallo: "welt",
        },
    });
    // Link a server to a primary IP
    const serverTest = new hcloud.Server("serverTest", {
        image: "ubuntu-20.04",
        serverType: "cx11",
        datacenter: "fsn1-dc14",
        labels: {
            test: "tessst1",
        },
        publicNets: [{
            ipv4: main.id,
        }],
    });
    
    resources:
      main:
        type: hcloud:PrimaryIp
        properties:
          datacenter: fsn1-dc14
          type: ipv4
          assigneeType: server
          autoDelete: true
          labels:
            hallo: welt
      # Link a server to a primary IP
      serverTest:
        type: hcloud:Server
        properties:
          image: ubuntu-20.04
          serverType: cx11
          datacenter: fsn1-dc14
          labels:
            test: tessst1
          publicNets:
            - ipv4: ${main.id}
    

    Create PrimaryIp Resource

    new PrimaryIp(name: string, args: PrimaryIpArgs, opts?: CustomResourceOptions);
    @overload
    def PrimaryIp(resource_name: 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,
                  labels: Optional[Mapping[str, Any]] = None,
                  name: Optional[str] = None,
                  type: Optional[str] = None)
    @overload
    def PrimaryIp(resource_name: str,
                  args: PrimaryIpArgs,
                  opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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

    The PrimaryIp resource accepts the following input properties:

    AssigneeType string

    The type of the assigned resource. Currently supported: server

    AutoDelete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    Type string

    Type of the Primary IP. ipv4 or ipv6

    AssigneeId int

    ID of the assigned resource

    Datacenter string

    The datacenter name to create the resource in.

    DeleteProtection bool

    Whether delete protection is enabled.

    Labels Dictionary<string, object>

    Description of the Primary IP.

    Name string

    Name of the Primary IP.

    AssigneeType string

    The type of the assigned resource. Currently supported: server

    AutoDelete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    Type string

    Type of the Primary IP. ipv4 or ipv6

    AssigneeId int

    ID of the assigned resource

    Datacenter string

    The datacenter name to create the resource in.

    DeleteProtection bool

    Whether delete protection is enabled.

    Labels map[string]interface{}

    Description of the Primary IP.

    Name string

    Name of the Primary IP.

    assigneeType String

    The type of the assigned resource. Currently supported: server

    autoDelete Boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    type String

    Type of the Primary IP. ipv4 or ipv6

    assigneeId Integer

    ID of the assigned resource

    datacenter String

    The datacenter name to create the resource in.

    deleteProtection Boolean

    Whether delete protection is enabled.

    labels Map<String,Object>

    Description of the Primary IP.

    name String

    Name of the Primary IP.

    assigneeType string

    The type of the assigned resource. Currently supported: server

    autoDelete boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    type string

    Type of the Primary IP. ipv4 or ipv6

    assigneeId number

    ID of the assigned resource

    datacenter string

    The datacenter name to create the resource in.

    deleteProtection boolean

    Whether delete protection is enabled.

    labels {[key: string]: any}

    Description of the Primary IP.

    name string

    Name of the Primary IP.

    assignee_type str

    The type of the assigned resource. Currently supported: server

    auto_delete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    type str

    Type of the Primary IP. ipv4 or ipv6

    assignee_id int

    ID of the assigned resource

    datacenter str

    The datacenter name to create the resource in.

    delete_protection bool

    Whether delete protection is enabled.

    labels Mapping[str, Any]

    Description of the Primary IP.

    name str

    Name of the Primary IP.

    assigneeType String

    The type of the assigned resource. Currently supported: server

    autoDelete Boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    type String

    Type of the Primary IP. ipv4 or ipv6

    assigneeId Number

    ID of the assigned resource

    datacenter String

    The datacenter name to create the resource in.

    deleteProtection Boolean

    Whether delete protection is enabled.

    labels Map<Any>

    Description of the Primary IP.

    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 string

    The provider-assigned unique ID for this managed resource.

    IpAddress string

    (string) IP Address of the Primary IP.

    IpNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    Id string

    The provider-assigned unique ID for this managed resource.

    IpAddress string

    (string) IP Address of the Primary IP.

    IpNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    id String

    The provider-assigned unique ID for this managed resource.

    ipAddress String

    (string) IP Address of the Primary IP.

    ipNetwork String

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    id string

    The provider-assigned unique ID for this managed resource.

    ipAddress string

    (string) IP Address of the Primary IP.

    ipNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    id str

    The provider-assigned unique ID for this managed resource.

    ip_address str

    (string) IP Address of the Primary IP.

    ip_network str

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    id String

    The provider-assigned unique ID for this managed resource.

    ipAddress String

    (string) IP Address of the Primary IP.

    ipNetwork String

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    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, Any]] = None,
            name: Optional[str] = None,
            type: Optional[str] = None) -> PrimaryIp
    func 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)
    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.
    The following state arguments are supported:
    AssigneeId int

    ID of the assigned resource

    AssigneeType string

    The type of the assigned resource. Currently supported: server

    AutoDelete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    Datacenter string

    The datacenter name to create the resource in.

    DeleteProtection bool

    Whether delete protection is enabled.

    IpAddress string

    (string) IP Address of the Primary IP.

    IpNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    Labels Dictionary<string, object>

    Description of the Primary IP.

    Name string

    Name of the Primary IP.

    Type string

    Type of the Primary IP. ipv4 or ipv6

    AssigneeId int

    ID of the assigned resource

    AssigneeType string

    The type of the assigned resource. Currently supported: server

    AutoDelete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    Datacenter string

    The datacenter name to create the resource in.

    DeleteProtection bool

    Whether delete protection is enabled.

    IpAddress string

    (string) IP Address of the Primary IP.

    IpNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    Labels map[string]interface{}

    Description of the Primary IP.

    Name string

    Name of the Primary IP.

    Type string

    Type of the Primary IP. ipv4 or ipv6

    assigneeId Integer

    ID of the assigned resource

    assigneeType String

    The type of the assigned resource. Currently supported: server

    autoDelete Boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    datacenter String

    The datacenter name to create the resource in.

    deleteProtection Boolean

    Whether delete protection is enabled.

    ipAddress String

    (string) IP Address of the Primary IP.

    ipNetwork String

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    labels Map<String,Object>

    Description of the Primary IP.

    name String

    Name of the Primary IP.

    type String

    Type of the Primary IP. ipv4 or ipv6

    assigneeId number

    ID of the assigned resource

    assigneeType string

    The type of the assigned resource. Currently supported: server

    autoDelete boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    datacenter string

    The datacenter name to create the resource in.

    deleteProtection boolean

    Whether delete protection is enabled.

    ipAddress string

    (string) IP Address of the Primary IP.

    ipNetwork string

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    labels {[key: string]: any}

    Description of the Primary IP.

    name string

    Name of the Primary IP.

    type string

    Type of the Primary IP. ipv4 or ipv6

    assignee_id int

    ID of the assigned resource

    assignee_type str

    The type of the assigned resource. Currently supported: server

    auto_delete bool

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    datacenter str

    The datacenter name to create the resource in.

    delete_protection bool

    Whether delete protection is enabled.

    ip_address str

    (string) IP Address of the Primary IP.

    ip_network str

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    labels Mapping[str, Any]

    Description of the Primary IP.

    name str

    Name of the Primary IP.

    type str

    Type of the Primary IP. ipv4 or ipv6

    assigneeId Number

    ID of the assigned resource

    assigneeType String

    The type of the assigned resource. Currently supported: server

    autoDelete Boolean

    Whether auto delete is enabled. Important note:It is recommended to set auto_delete to false, because if a server assigned to the managed ip is getting deleted, it will also delete the primary IP which will break the TF state.

    datacenter String

    The datacenter name to create the resource in.

    deleteProtection Boolean

    Whether delete protection is enabled.

    ipAddress String

    (string) IP Address of the Primary IP.

    ipNetwork String

    (string) IPv6 subnet of the Primary IP for IPv6 addresses. (Only set if type is ipv6)

    labels Map<Any>

    Description of the Primary IP.

    name String

    Name of the Primary IP.

    type String

    Type of the Primary IP. ipv4 or ipv6

    Import

    Primary IPs can be imported using its id

     $ pulumi import hcloud:index/primaryIp:PrimaryIp myip id
    

    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.14.1 published on Monday, Aug 14, 2023 by Pulumi