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,
});
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"])
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
})
}
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,
});
});
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());
}
}
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}
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 string
- The unique name of the resource.
- args DevicePrimaryIpArgs
- 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 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 string
- The unique name of the resource.
- args DevicePrimaryIpArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DevicePrimaryIpArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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,
});
example, err := netbox.NewDevicePrimaryIp(ctx, "devicePrimaryIpResource", &netbox.DevicePrimaryIpArgs{
DeviceId: pulumi.Float64(0),
IpAddressId: pulumi.Float64(0),
DevicePrimaryIpId: pulumi.String("string"),
IpAddressVersion: pulumi.Float64(0),
})
var devicePrimaryIpResource = new DevicePrimaryIp("devicePrimaryIpResource", DevicePrimaryIpArgs.builder()
.deviceId(0)
.ipAddressId(0)
.devicePrimaryIpId("string")
.ipAddressVersion(0)
.build());
device_primary_ip_resource = netbox.DevicePrimaryIp("devicePrimaryIpResource",
device_id=0,
ip_address_id=0,
device_primary_ip_id="string",
ip_address_version=0)
const devicePrimaryIpResource = new netbox.DevicePrimaryIp("devicePrimaryIpResource", {
deviceId: 0,
ipAddressId: 0,
devicePrimaryIpId: "string",
ipAddressVersion: 0,
});
type: netbox:DevicePrimaryIp
properties:
deviceId: 0
devicePrimaryIpId: string
ipAddressId: 0
ipAddressVersion: 0
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:
- Device
Id double - Ip
Address doubleId - Device
Primary stringIp Id - The ID of this resource.
- Ip
Address doubleVersion - Defaults to
4
.
- Device
Id float64 - Ip
Address float64Id - Device
Primary stringIp Id - The ID of this resource.
- Ip
Address float64Version - Defaults to
4
.
- device
Id Double - ip
Address DoubleId - device
Primary StringIp Id - The ID of this resource.
- ip
Address DoubleVersion - Defaults to
4
.
- device
Id number - ip
Address numberId - device
Primary stringIp Id - The ID of this resource.
- ip
Address numberVersion - Defaults to
4
.
- device_
id float - ip_
address_ floatid - device_
primary_ strip_ id - The ID of this resource.
- ip_
address_ floatversion - Defaults to
4
.
- device
Id Number - ip
Address NumberId - device
Primary StringIp Id - The ID of this resource.
- ip
Address NumberVersion - 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
- 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.
- Device
Id double - Device
Primary stringIp Id - The ID of this resource.
- Ip
Address doubleId - Ip
Address doubleVersion - Defaults to
4
.
- Device
Id float64 - Device
Primary stringIp Id - The ID of this resource.
- Ip
Address float64Id - Ip
Address float64Version - Defaults to
4
.
- device
Id Double - device
Primary StringIp Id - The ID of this resource.
- ip
Address DoubleId - ip
Address DoubleVersion - Defaults to
4
.
- device
Id number - device
Primary stringIp Id - The ID of this resource.
- ip
Address numberId - ip
Address numberVersion - Defaults to
4
.
- device_
id float - device_
primary_ strip_ id - The ID of this resource.
- ip_
address_ floatid - ip_
address_ floatversion - Defaults to
4
.
- device
Id Number - device
Primary StringIp Id - The ID of this resource.
- ip
Address NumberId - ip
Address NumberVersion - Defaults to
4
.
Package Details
- Repository
- netbox e-breuninger/terraform-provider-netbox
- License
- Notes
- This Pulumi package is based on the
netbox
Terraform Provider.