1. Packages
  2. Netbox Provider
  3. API Docs
  4. DevicePrimaryIp
netbox 3.10.0 published on Monday, Apr 14, 2025 by e-breuninger

netbox.DevicePrimaryIp

Explore with Pulumi AI

This resource is used to define the primary IP for a given device. The primary IP is reflected in the device Netbox UI, which identifies the Primary IPv4 and IPv6 addresses.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as netbox from "@pulumi/netbox";

// Note that some terraform code is not included in the example for brevity
const test = new netbox.Device("test", {
    deviceTypeId: netbox_device_type.test.id,
    roleId: netbox_device_role.test.id,
    siteId: netbox_site.test.id,
});
const testV4IpAddress = new netbox.IpAddress("testV4IpAddress", {
    ipAddress: "1.1.1.1/32",
    status: "active",
    deviceInterfaceId: netbox_device_interface.test.id,
});
const testV4DevicePrimaryIp = new netbox.DevicePrimaryIp("testV4DevicePrimaryIp", {
    deviceId: test.deviceId,
    ipAddressId: netbox_ip_address.test.id,
});
Copy
import pulumi
import pulumi_netbox as netbox

# Note that some terraform code is not included in the example for brevity
test = netbox.Device("test",
    device_type_id=netbox_device_type["test"]["id"],
    role_id=netbox_device_role["test"]["id"],
    site_id=netbox_site["test"]["id"])
test_v4_ip_address = netbox.IpAddress("testV4IpAddress",
    ip_address="1.1.1.1/32",
    status="active",
    device_interface_id=netbox_device_interface["test"]["id"])
test_v4_device_primary_ip = netbox.DevicePrimaryIp("testV4DevicePrimaryIp",
    device_id=test.device_id,
    ip_address_id=netbox_ip_address["test"]["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/netbox/v3/netbox"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Note that some terraform code is not included in the example for brevity
		test, err := netbox.NewDevice(ctx, "test", &netbox.DeviceArgs{
			DeviceTypeId: pulumi.Any(netbox_device_type.Test.Id),
			RoleId:       pulumi.Any(netbox_device_role.Test.Id),
			SiteId:       pulumi.Any(netbox_site.Test.Id),
		})
		if err != nil {
			return err
		}
		_, err = netbox.NewIpAddress(ctx, "testV4IpAddress", &netbox.IpAddressArgs{
			IpAddress:         pulumi.String("1.1.1.1/32"),
			Status:            pulumi.String("active"),
			DeviceInterfaceId: pulumi.Any(netbox_device_interface.Test.Id),
		})
		if err != nil {
			return err
		}
		_, err = netbox.NewDevicePrimaryIp(ctx, "testV4DevicePrimaryIp", &netbox.DevicePrimaryIpArgs{
			DeviceId:    test.DeviceId,
			IpAddressId: pulumi.Any(netbox_ip_address.Test.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Netbox = Pulumi.Netbox;

return await Deployment.RunAsync(() => 
{
    // Note that some terraform code is not included in the example for brevity
    var test = new Netbox.Device("test", new()
    {
        DeviceTypeId = netbox_device_type.Test.Id,
        RoleId = netbox_device_role.Test.Id,
        SiteId = netbox_site.Test.Id,
    });

    var testV4IpAddress = new Netbox.IpAddress("testV4IpAddress", new()
    {
        IpAddress = "1.1.1.1/32",
        Status = "active",
        DeviceInterfaceId = netbox_device_interface.Test.Id,
    });

    var testV4DevicePrimaryIp = new Netbox.DevicePrimaryIp("testV4DevicePrimaryIp", new()
    {
        DeviceId = test.DeviceId,
        IpAddressId = netbox_ip_address.Test.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.netbox.Device;
import com.pulumi.netbox.DeviceArgs;
import com.pulumi.netbox.IpAddress;
import com.pulumi.netbox.IpAddressArgs;
import com.pulumi.netbox.DevicePrimaryIp;
import com.pulumi.netbox.DevicePrimaryIpArgs;
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) {
        // Note that some terraform code is not included in the example for brevity
        var test = new Device("test", DeviceArgs.builder()
            .deviceTypeId(netbox_device_type.test().id())
            .roleId(netbox_device_role.test().id())
            .siteId(netbox_site.test().id())
            .build());

        var testV4IpAddress = new IpAddress("testV4IpAddress", IpAddressArgs.builder()
            .ipAddress("1.1.1.1/32")
            .status("active")
            .deviceInterfaceId(netbox_device_interface.test().id())
            .build());

        var testV4DevicePrimaryIp = new DevicePrimaryIp("testV4DevicePrimaryIp", DevicePrimaryIpArgs.builder()
            .deviceId(test.deviceId())
            .ipAddressId(netbox_ip_address.test().id())
            .build());

    }
}
Copy
resources:
  # Note that some terraform code is not included in the example for brevity
  test:
    type: netbox:Device
    properties:
      deviceTypeId: ${netbox_device_type.test.id}
      roleId: ${netbox_device_role.test.id}
      siteId: ${netbox_site.test.id}
  testV4IpAddress:
    type: netbox:IpAddress
    properties:
      ipAddress: 1.1.1.1/32
      status: active
      deviceInterfaceId: ${netbox_device_interface.test.id}
  testV4DevicePrimaryIp:
    type: netbox:DevicePrimaryIp
    properties:
      deviceId: ${test.deviceId}
      ipAddressId: ${netbox_ip_address.test.id}
Copy

Create DevicePrimaryIp Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new DevicePrimaryIp(name: string, args: DevicePrimaryIpArgs, opts?: CustomResourceOptions);
@overload
def DevicePrimaryIp(resource_name: str,
                    args: DevicePrimaryIpArgs,
                    opts: Optional[ResourceOptions] = None)

@overload
def DevicePrimaryIp(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    device_id: Optional[float] = None,
                    ip_address_id: Optional[float] = None,
                    device_primary_ip_id: Optional[str] = None,
                    ip_address_version: Optional[float] = None)
func NewDevicePrimaryIp(ctx *Context, name string, args DevicePrimaryIpArgs, opts ...ResourceOption) (*DevicePrimaryIp, error)
public DevicePrimaryIp(string name, DevicePrimaryIpArgs args, CustomResourceOptions? opts = null)
public DevicePrimaryIp(String name, DevicePrimaryIpArgs args)
public DevicePrimaryIp(String name, DevicePrimaryIpArgs args, CustomResourceOptions options)
type: netbox:DevicePrimaryIp
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DevicePrimaryIpArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DevicePrimaryIpArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DevicePrimaryIpArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DevicePrimaryIpArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DevicePrimaryIpArgs
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 devicePrimaryIpResource = new Netbox.DevicePrimaryIp("devicePrimaryIpResource", new()
{
    DeviceId = 0,
    IpAddressId = 0,
    DevicePrimaryIpId = "string",
    IpAddressVersion = 0,
});
Copy
example, err := netbox.NewDevicePrimaryIp(ctx, "devicePrimaryIpResource", &netbox.DevicePrimaryIpArgs{
DeviceId: pulumi.Float64(0),
IpAddressId: pulumi.Float64(0),
DevicePrimaryIpId: pulumi.String("string"),
IpAddressVersion: pulumi.Float64(0),
})
Copy
var devicePrimaryIpResource = new DevicePrimaryIp("devicePrimaryIpResource", DevicePrimaryIpArgs.builder()
    .deviceId(0)
    .ipAddressId(0)
    .devicePrimaryIpId("string")
    .ipAddressVersion(0)
    .build());
Copy
device_primary_ip_resource = netbox.DevicePrimaryIp("devicePrimaryIpResource",
    device_id=0,
    ip_address_id=0,
    device_primary_ip_id="string",
    ip_address_version=0)
Copy
const devicePrimaryIpResource = new netbox.DevicePrimaryIp("devicePrimaryIpResource", {
    deviceId: 0,
    ipAddressId: 0,
    devicePrimaryIpId: "string",
    ipAddressVersion: 0,
});
Copy
type: netbox:DevicePrimaryIp
properties:
    deviceId: 0
    devicePrimaryIpId: string
    ipAddressId: 0
    ipAddressVersion: 0
Copy

DevicePrimaryIp 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 DevicePrimaryIp resource accepts the following input properties:

DeviceId This property is required. double
IpAddressId This property is required. double
DevicePrimaryIpId string
The ID of this resource.
IpAddressVersion double
Defaults to 4.
DeviceId This property is required. float64
IpAddressId This property is required. float64
DevicePrimaryIpId string
The ID of this resource.
IpAddressVersion float64
Defaults to 4.
deviceId This property is required. Double
ipAddressId This property is required. Double
devicePrimaryIpId String
The ID of this resource.
ipAddressVersion Double
Defaults to 4.
deviceId This property is required. number
ipAddressId This property is required. number
devicePrimaryIpId string
The ID of this resource.
ipAddressVersion number
Defaults to 4.
device_id This property is required. float
ip_address_id This property is required. float
device_primary_ip_id str
The ID of this resource.
ip_address_version float
Defaults to 4.
deviceId This property is required. Number
ipAddressId This property is required. Number
devicePrimaryIpId String
The ID of this resource.
ipAddressVersion Number
Defaults to 4.

Outputs

All input properties are implicitly available as output properties. Additionally, the DevicePrimaryIp 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 DevicePrimaryIp Resource

Get an existing DevicePrimaryIp 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?: DevicePrimaryIpState, opts?: CustomResourceOptions): DevicePrimaryIp
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        device_id: Optional[float] = None,
        device_primary_ip_id: Optional[str] = None,
        ip_address_id: Optional[float] = None,
        ip_address_version: Optional[float] = None) -> DevicePrimaryIp
func GetDevicePrimaryIp(ctx *Context, name string, id IDInput, state *DevicePrimaryIpState, opts ...ResourceOption) (*DevicePrimaryIp, error)
public static DevicePrimaryIp Get(string name, Input<string> id, DevicePrimaryIpState? state, CustomResourceOptions? opts = null)
public static DevicePrimaryIp get(String name, Output<String> id, DevicePrimaryIpState state, CustomResourceOptions options)
resources:  _:    type: netbox:DevicePrimaryIp    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
DeviceId double
DevicePrimaryIpId string
The ID of this resource.
IpAddressId double
IpAddressVersion double
Defaults to 4.
DeviceId float64
DevicePrimaryIpId string
The ID of this resource.
IpAddressId float64
IpAddressVersion float64
Defaults to 4.
deviceId Double
devicePrimaryIpId String
The ID of this resource.
ipAddressId Double
ipAddressVersion Double
Defaults to 4.
deviceId number
devicePrimaryIpId string
The ID of this resource.
ipAddressId number
ipAddressVersion number
Defaults to 4.
device_id float
device_primary_ip_id str
The ID of this resource.
ip_address_id float
ip_address_version float
Defaults to 4.
deviceId Number
devicePrimaryIpId String
The ID of this resource.
ipAddressId Number
ipAddressVersion Number
Defaults to 4.

Package Details

Repository
netbox e-breuninger/terraform-provider-netbox
License
Notes
This Pulumi package is based on the netbox Terraform Provider.