1. Packages
  2. Hcloud Provider
  3. API Docs
  4. PrimaryIp
Hetzner Cloud v1.20.4 published on Tuesday, Sep 24, 2024 by Pulumi

hcloud.PrimaryIp

Explore with Pulumi AI

hcloud logo
Hetzner Cloud v1.20.4 published on Tuesday, Sep 24, 2024 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

    import * as pulumi from "@pulumi/pulumi";
    import * as hcloud from "@pulumi/hcloud";
    
    const main = new hcloud.PrimaryIp("main", {
        name: "primary_ip_test",
        datacenter: "fsn1-dc14",
        type: "ipv4",
        assigneeType: "server",
        autoDelete: true,
        labels: {
            hallo: "welt",
        },
    });
    // Link a server to a primary IP
    const serverTest = new hcloud.Server("server_test", {
        name: "test-server",
        image: "ubuntu-20.04",
        serverType: "cx22",
        datacenter: "fsn1-dc14",
        labels: {
            test: "tessst1",
        },
        publicNets: [{
            ipv4: main.id,
        }],
    });
    
    import pulumi
    import pulumi_hcloud as hcloud
    
    main = hcloud.PrimaryIp("main",
        name="primary_ip_test",
        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("server_test",
        name="test-server",
        image="ubuntu-20.04",
        server_type="cx22",
        datacenter="fsn1-dc14",
        labels={
            "test": "tessst1",
        },
        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_test"),
    			Datacenter:   pulumi.String("fsn1-dc14"),
    			Type:         pulumi.String("ipv4"),
    			AssigneeType: pulumi.String("server"),
    			AutoDelete:   pulumi.Bool(true),
    			Labels: pulumi.StringMap{
    				"hallo": pulumi.String("welt"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Link a server to a primary IP
    		_, err = hcloud.NewServer(ctx, "server_test", &hcloud.ServerArgs{
    			Name:       pulumi.String("test-server"),
    			Image:      pulumi.String("ubuntu-20.04"),
    			ServerType: pulumi.String("cx22"),
    			Datacenter: pulumi.String("fsn1-dc14"),
    			Labels: pulumi.StringMap{
    				"test": pulumi.String("tessst1"),
    			},
    			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.PrimaryIp("main", new()
        {
            Name = "primary_ip_test",
            Datacenter = "fsn1-dc14",
            Type = "ipv4",
            AssigneeType = "server",
            AutoDelete = true,
            Labels = 
            {
                { "hallo", "welt" },
            },
        });
    
        // Link a server to a primary IP
        var serverTest = new HCloud.Server("server_test", new()
        {
            Name = "test-server",
            Image = "ubuntu-20.04",
            ServerType = "cx22",
            Datacenter = "fsn1-dc14",
            Labels = 
            {
                { "test", "tessst1" },
            },
            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_test")
                .datacenter("fsn1-dc14")
                .type("ipv4")
                .assigneeType("server")
                .autoDelete(true)
                .labels(Map.of("hallo", "welt"))
                .build());
    
            // Link a server to a primary IP
            var serverTest = new Server("serverTest", ServerArgs.builder()
                .name("test-server")
                .image("ubuntu-20.04")
                .serverType("cx22")
                .datacenter("fsn1-dc14")
                .labels(Map.of("test", "tessst1"))
                .publicNets(ServerPublicNetArgs.builder()
                    .ipv4(main.id())
                    .build())
                .build());
    
        }
    }
    
    resources:
      main:
        type: hcloud:PrimaryIp
        properties:
          name: primary_ip_test
          datacenter: fsn1-dc14
          type: ipv4
          assigneeType: server
          autoDelete: true
          labels:
            hallo: welt
      # Link a server to a primary IP
      serverTest:
        type: hcloud:Server
        name: server_test
        properties:
          name: test-server
          image: ubuntu-20.04
          serverType: cx22
          datacenter: fsn1-dc14
          labels:
            test: tessst1
          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,
                  assignee_type: Optional[str] = None,
                  auto_delete: Optional[bool] = None,
                  type: Optional[str] = None,
                  assignee_id: Optional[int] = None,
                  datacenter: Optional[str] = None,
                  delete_protection: Optional[bool] = None,
                  labels: Optional[Mapping[str, 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()
    {
        AssigneeType = "string",
        AutoDelete = false,
        Type = "string",
        AssigneeId = 0,
        Datacenter = "string",
        DeleteProtection = false,
        Labels = 
        {
            { "string", "string" },
        },
        Name = "string",
    });
    
    example, err := hcloud.NewPrimaryIp(ctx, "primaryIpResource", &hcloud.PrimaryIpArgs{
    	AssigneeType:     pulumi.String("string"),
    	AutoDelete:       pulumi.Bool(false),
    	Type:             pulumi.String("string"),
    	AssigneeId:       pulumi.Int(0),
    	Datacenter:       pulumi.String("string"),
    	DeleteProtection: pulumi.Bool(false),
    	Labels: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	Name: pulumi.String("string"),
    })
    
    var primaryIpResource = new PrimaryIp("primaryIpResource", PrimaryIpArgs.builder()
        .assigneeType("string")
        .autoDelete(false)
        .type("string")
        .assigneeId(0)
        .datacenter("string")
        .deleteProtection(false)
        .labels(Map.of("string", "string"))
        .name("string")
        .build());
    
    primary_ip_resource = hcloud.PrimaryIp("primaryIpResource",
        assignee_type="string",
        auto_delete=False,
        type="string",
        assignee_id=0,
        datacenter="string",
        delete_protection=False,
        labels={
            "string": "string",
        },
        name="string")
    
    const primaryIpResource = new hcloud.PrimaryIp("primaryIpResource", {
        assigneeType: "string",
        autoDelete: false,
        type: "string",
        assigneeId: 0,
        datacenter: "string",
        deleteProtection: false,
        labels: {
            string: "string",
        },
        name: "string",
    });
    
    type: hcloud:PrimaryIp
    properties:
        assigneeId: 0
        assigneeType: string
        autoDelete: false
        datacenter: string
        deleteProtection: false
        labels:
            string: 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

    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. See "Delete Protection" in the Provider Docs for details.
    Labels Dictionary<string, string>
    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. See "Delete Protection" in the Provider Docs for details.
    Labels map[string]string
    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. See "Delete Protection" in the Provider Docs for details.
    labels Map<String,String>
    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. See "Delete Protection" in the Provider Docs for details.
    labels {[key: string]: string}
    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. See "Delete Protection" in the Provider Docs for details.
    labels Mapping[str, str]
    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. See "Delete Protection" in the Provider Docs for details.
    labels Map<String>
    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, str]] = 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. See "Delete Protection" in the Provider Docs for details.
    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, string>
    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. See "Delete Protection" in the Provider Docs for details.
    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]string
    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. See "Delete Protection" in the Provider Docs for details.
    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,String>
    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. See "Delete Protection" in the Provider Docs for details.
    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]: string}
    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. See "Delete Protection" in the Provider Docs for details.
    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, str]
    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. See "Delete Protection" in the Provider Docs for details.
    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>
    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
    

    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.
    hcloud logo
    Hetzner Cloud v1.20.4 published on Tuesday, Sep 24, 2024 by Pulumi