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

netbox.Prefix

Explore with Pulumi AI

From the official documentation:

A prefix is an IPv4 or IPv6 network and mask expressed in CIDR notation (e.g. 192.0.2.0/24). A prefix entails only the “network portion” of an IP address: All bits in the address not covered by the mask must be zero. (In other words, a prefix cannot be a specific IP address.)

Prefixes are automatically organized by their parent aggregates. Additionally, each prefix can be assigned to a particular site and virtual routing and forwarding instance (VRF). Each VRF represents a separate IP space or routing table. All prefixes not assigned to a VRF are considered to be in the “global” table.

Example Usage

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

const myPrefix = new netbox.Prefix("myPrefix", {
    description: "test prefix",
    prefix: "10.0.0.0/24",
    status: "active",
});
Copy
import pulumi
import pulumi_netbox as netbox

my_prefix = netbox.Prefix("myPrefix",
    description="test prefix",
    prefix="10.0.0.0/24",
    status="active")
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 {
		_, err := netbox.NewPrefix(ctx, "myPrefix", &netbox.PrefixArgs{
			Description: pulumi.String("test prefix"),
			Prefix:      pulumi.String("10.0.0.0/24"),
			Status:      pulumi.String("active"),
		})
		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(() => 
{
    var myPrefix = new Netbox.Prefix("myPrefix", new()
    {
        Description = "test prefix",
        Prefix = "10.0.0.0/24",
        Status = "active",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.netbox.Prefix;
import com.pulumi.netbox.PrefixArgs;
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 myPrefix = new Prefix("myPrefix", PrefixArgs.builder()
            .description("test prefix")
            .prefix("10.0.0.0/24")
            .status("active")
            .build());

    }
}
Copy
resources:
  myPrefix:
    type: netbox:Prefix
    properties:
      description: test prefix
      prefix: 10.0.0.0/24
      status: active
Copy

Create Prefix Resource

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

Constructor syntax

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

@overload
def Prefix(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           prefix: Optional[str] = None,
           status: Optional[str] = None,
           role_id: Optional[float] = None,
           mark_utilized: Optional[bool] = None,
           is_pool: Optional[bool] = None,
           prefix_id: Optional[str] = None,
           custom_fields: Optional[Mapping[str, str]] = None,
           site_id: Optional[float] = None,
           description: Optional[str] = None,
           tags: Optional[Sequence[str]] = None,
           tenant_id: Optional[float] = None,
           vlan_id: Optional[float] = None,
           vrf_id: Optional[float] = None)
func NewPrefix(ctx *Context, name string, args PrefixArgs, opts ...ResourceOption) (*Prefix, error)
public Prefix(string name, PrefixArgs args, CustomResourceOptions? opts = null)
public Prefix(String name, PrefixArgs args)
public Prefix(String name, PrefixArgs args, CustomResourceOptions options)
type: netbox:Prefix
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. PrefixArgs
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. PrefixArgs
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. PrefixArgs
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. PrefixArgs
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. PrefixArgs
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 prefixResource = new Netbox.Prefix("prefixResource", new()
{
    Prefix = "string",
    Status = "string",
    RoleId = 0,
    MarkUtilized = false,
    IsPool = false,
    PrefixId = "string",
    CustomFields = 
    {
        { "string", "string" },
    },
    SiteId = 0,
    Description = "string",
    Tags = new[]
    {
        "string",
    },
    TenantId = 0,
    VlanId = 0,
    VrfId = 0,
});
Copy
example, err := netbox.NewPrefix(ctx, "prefixResource", &netbox.PrefixArgs{
Prefix: pulumi.String("string"),
Status: pulumi.String("string"),
RoleId: pulumi.Float64(0),
MarkUtilized: pulumi.Bool(false),
IsPool: pulumi.Bool(false),
PrefixId: pulumi.String("string"),
CustomFields: pulumi.StringMap{
"string": pulumi.String("string"),
},
SiteId: pulumi.Float64(0),
Description: pulumi.String("string"),
Tags: pulumi.StringArray{
pulumi.String("string"),
},
TenantId: pulumi.Float64(0),
VlanId: pulumi.Float64(0),
VrfId: pulumi.Float64(0),
})
Copy
var prefixResource = new Prefix("prefixResource", PrefixArgs.builder()
    .prefix("string")
    .status("string")
    .roleId(0)
    .markUtilized(false)
    .isPool(false)
    .prefixId("string")
    .customFields(Map.of("string", "string"))
    .siteId(0)
    .description("string")
    .tags("string")
    .tenantId(0)
    .vlanId(0)
    .vrfId(0)
    .build());
Copy
prefix_resource = netbox.Prefix("prefixResource",
    prefix="string",
    status="string",
    role_id=0,
    mark_utilized=False,
    is_pool=False,
    prefix_id="string",
    custom_fields={
        "string": "string",
    },
    site_id=0,
    description="string",
    tags=["string"],
    tenant_id=0,
    vlan_id=0,
    vrf_id=0)
Copy
const prefixResource = new netbox.Prefix("prefixResource", {
    prefix: "string",
    status: "string",
    roleId: 0,
    markUtilized: false,
    isPool: false,
    prefixId: "string",
    customFields: {
        string: "string",
    },
    siteId: 0,
    description: "string",
    tags: ["string"],
    tenantId: 0,
    vlanId: 0,
    vrfId: 0,
});
Copy
type: netbox:Prefix
properties:
    customFields:
        string: string
    description: string
    isPool: false
    markUtilized: false
    prefix: string
    prefixId: string
    roleId: 0
    siteId: 0
    status: string
    tags:
        - string
    tenantId: 0
    vlanId: 0
    vrfId: 0
Copy

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

Prefix This property is required. string
Status This property is required. string
Valid values are active, container, reserved and deprecated.
CustomFields Dictionary<string, string>
Description string
IsPool bool
MarkUtilized bool
PrefixId string
The ID of this resource.
RoleId double
SiteId double
Tags List<string>
TenantId double
VlanId double
VrfId double
Prefix This property is required. string
Status This property is required. string
Valid values are active, container, reserved and deprecated.
CustomFields map[string]string
Description string
IsPool bool
MarkUtilized bool
PrefixId string
The ID of this resource.
RoleId float64
SiteId float64
Tags []string
TenantId float64
VlanId float64
VrfId float64
prefix This property is required. String
status This property is required. String
Valid values are active, container, reserved and deprecated.
customFields Map<String,String>
description String
isPool Boolean
markUtilized Boolean
prefixId String
The ID of this resource.
roleId Double
siteId Double
tags List<String>
tenantId Double
vlanId Double
vrfId Double
prefix This property is required. string
status This property is required. string
Valid values are active, container, reserved and deprecated.
customFields {[key: string]: string}
description string
isPool boolean
markUtilized boolean
prefixId string
The ID of this resource.
roleId number
siteId number
tags string[]
tenantId number
vlanId number
vrfId number
prefix This property is required. str
status This property is required. str
Valid values are active, container, reserved and deprecated.
custom_fields Mapping[str, str]
description str
is_pool bool
mark_utilized bool
prefix_id str
The ID of this resource.
role_id float
site_id float
tags Sequence[str]
tenant_id float
vlan_id float
vrf_id float
prefix This property is required. String
status This property is required. String
Valid values are active, container, reserved and deprecated.
customFields Map<String>
description String
isPool Boolean
markUtilized Boolean
prefixId String
The ID of this resource.
roleId Number
siteId Number
tags List<String>
tenantId Number
vlanId Number
vrfId Number

Outputs

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

Get an existing Prefix 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?: PrefixState, opts?: CustomResourceOptions): Prefix
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        custom_fields: Optional[Mapping[str, str]] = None,
        description: Optional[str] = None,
        is_pool: Optional[bool] = None,
        mark_utilized: Optional[bool] = None,
        prefix: Optional[str] = None,
        prefix_id: Optional[str] = None,
        role_id: Optional[float] = None,
        site_id: Optional[float] = None,
        status: Optional[str] = None,
        tags: Optional[Sequence[str]] = None,
        tenant_id: Optional[float] = None,
        vlan_id: Optional[float] = None,
        vrf_id: Optional[float] = None) -> Prefix
func GetPrefix(ctx *Context, name string, id IDInput, state *PrefixState, opts ...ResourceOption) (*Prefix, error)
public static Prefix Get(string name, Input<string> id, PrefixState? state, CustomResourceOptions? opts = null)
public static Prefix get(String name, Output<String> id, PrefixState state, CustomResourceOptions options)
resources:  _:    type: netbox:Prefix    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:
CustomFields Dictionary<string, string>
Description string
IsPool bool
MarkUtilized bool
Prefix string
PrefixId string
The ID of this resource.
RoleId double
SiteId double
Status string
Valid values are active, container, reserved and deprecated.
Tags List<string>
TenantId double
VlanId double
VrfId double
CustomFields map[string]string
Description string
IsPool bool
MarkUtilized bool
Prefix string
PrefixId string
The ID of this resource.
RoleId float64
SiteId float64
Status string
Valid values are active, container, reserved and deprecated.
Tags []string
TenantId float64
VlanId float64
VrfId float64
customFields Map<String,String>
description String
isPool Boolean
markUtilized Boolean
prefix String
prefixId String
The ID of this resource.
roleId Double
siteId Double
status String
Valid values are active, container, reserved and deprecated.
tags List<String>
tenantId Double
vlanId Double
vrfId Double
customFields {[key: string]: string}
description string
isPool boolean
markUtilized boolean
prefix string
prefixId string
The ID of this resource.
roleId number
siteId number
status string
Valid values are active, container, reserved and deprecated.
tags string[]
tenantId number
vlanId number
vrfId number
custom_fields Mapping[str, str]
description str
is_pool bool
mark_utilized bool
prefix str
prefix_id str
The ID of this resource.
role_id float
site_id float
status str
Valid values are active, container, reserved and deprecated.
tags Sequence[str]
tenant_id float
vlan_id float
vrf_id float
customFields Map<String>
description String
isPool Boolean
markUtilized Boolean
prefix String
prefixId String
The ID of this resource.
roleId Number
siteId Number
status String
Valid values are active, container, reserved and deprecated.
tags List<String>
tenantId Number
vlanId Number
vrfId Number

Package Details

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