1. Packages
  2. Netbox Provider
  3. API Docs
  4. Prefix
netbox 4.0.0 published on Thursday, Jun 12, 2025 by e-breuninger

netbox.Prefix

Explore with Pulumi AI

netbox logo
netbox 4.0.0 published on Thursday, Jun 12, 2025 by e-breuninger

    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",
    });
    
    import pulumi
    import pulumi_netbox as netbox
    
    my_prefix = netbox.Prefix("myPrefix",
        description="test prefix",
        prefix="10.0.0.0/24",
        status="active")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/netbox/v4/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
    	})
    }
    
    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",
        });
    
    });
    
    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());
    
        }
    }
    
    resources:
      myPrefix:
        type: netbox:Prefix
        properties:
          description: test prefix
          prefix: 10.0.0.0/24
          status: active
    

    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,
               site_group_id: Optional[float] = None,
               mark_utilized: Optional[bool] = None,
               is_pool: Optional[bool] = None,
               prefix_id: Optional[str] = None,
               region_id: Optional[float] = None,
               custom_fields: Optional[Mapping[str, str]] = None,
               location_id: Optional[float] = 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 string
    The unique name of the resource.
    args PrefixArgs
    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 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 string
    The unique name of the resource.
    args PrefixArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PrefixArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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,
        SiteGroupId = 0,
        MarkUtilized = false,
        IsPool = false,
        PrefixId = "string",
        RegionId = 0,
        CustomFields = 
        {
            { "string", "string" },
        },
        LocationId = 0,
        SiteId = 0,
        Description = "string",
        Tags = new[]
        {
            "string",
        },
        TenantId = 0,
        VlanId = 0,
        VrfId = 0,
    });
    
    example, err := netbox.NewPrefix(ctx, "prefixResource", &netbox.PrefixArgs{
    	Prefix:       pulumi.String("string"),
    	Status:       pulumi.String("string"),
    	RoleId:       pulumi.Float64(0),
    	SiteGroupId:  pulumi.Float64(0),
    	MarkUtilized: pulumi.Bool(false),
    	IsPool:       pulumi.Bool(false),
    	PrefixId:     pulumi.String("string"),
    	RegionId:     pulumi.Float64(0),
    	CustomFields: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	LocationId:  pulumi.Float64(0),
    	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),
    })
    
    var prefixResource = new Prefix("prefixResource", PrefixArgs.builder()
        .prefix("string")
        .status("string")
        .roleId(0.0)
        .siteGroupId(0.0)
        .markUtilized(false)
        .isPool(false)
        .prefixId("string")
        .regionId(0.0)
        .customFields(Map.of("string", "string"))
        .locationId(0.0)
        .siteId(0.0)
        .description("string")
        .tags("string")
        .tenantId(0.0)
        .vlanId(0.0)
        .vrfId(0.0)
        .build());
    
    prefix_resource = netbox.Prefix("prefixResource",
        prefix="string",
        status="string",
        role_id=0,
        site_group_id=0,
        mark_utilized=False,
        is_pool=False,
        prefix_id="string",
        region_id=0,
        custom_fields={
            "string": "string",
        },
        location_id=0,
        site_id=0,
        description="string",
        tags=["string"],
        tenant_id=0,
        vlan_id=0,
        vrf_id=0)
    
    const prefixResource = new netbox.Prefix("prefixResource", {
        prefix: "string",
        status: "string",
        roleId: 0,
        siteGroupId: 0,
        markUtilized: false,
        isPool: false,
        prefixId: "string",
        regionId: 0,
        customFields: {
            string: "string",
        },
        locationId: 0,
        siteId: 0,
        description: "string",
        tags: ["string"],
        tenantId: 0,
        vlanId: 0,
        vrfId: 0,
    });
    
    type: netbox:Prefix
    properties:
        customFields:
            string: string
        description: string
        isPool: false
        locationId: 0
        markUtilized: false
        prefix: string
        prefixId: string
        regionId: 0
        roleId: 0
        siteGroupId: 0
        siteId: 0
        status: string
        tags:
            - string
        tenantId: 0
        vlanId: 0
        vrfId: 0
    

    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 string
    Status string
    Valid values are active, container, reserved and deprecated.
    CustomFields Dictionary<string, string>
    Description string
    IsPool bool
    LocationId double
    Conflicts with site_id, site_group_id and region_id.
    MarkUtilized bool
    PrefixId string
    The ID of this resource.
    RegionId double
    Conflicts with location_id, site_id and site_group_id.
    RoleId double
    SiteGroupId double
    Conflicts with location_id, site_id and region_id.
    SiteId double
    Conflicts with location_id, site_group_id and region_id.
    Tags List<string>
    TenantId double
    VlanId double
    VrfId double
    Prefix string
    Status string
    Valid values are active, container, reserved and deprecated.
    CustomFields map[string]string
    Description string
    IsPool bool
    LocationId float64
    Conflicts with site_id, site_group_id and region_id.
    MarkUtilized bool
    PrefixId string
    The ID of this resource.
    RegionId float64
    Conflicts with location_id, site_id and site_group_id.
    RoleId float64
    SiteGroupId float64
    Conflicts with location_id, site_id and region_id.
    SiteId float64
    Conflicts with location_id, site_group_id and region_id.
    Tags []string
    TenantId float64
    VlanId float64
    VrfId float64
    prefix String
    status String
    Valid values are active, container, reserved and deprecated.
    customFields Map<String,String>
    description String
    isPool Boolean
    locationId Double
    Conflicts with site_id, site_group_id and region_id.
    markUtilized Boolean
    prefixId String
    The ID of this resource.
    regionId Double
    Conflicts with location_id, site_id and site_group_id.
    roleId Double
    siteGroupId Double
    Conflicts with location_id, site_id and region_id.
    siteId Double
    Conflicts with location_id, site_group_id and region_id.
    tags List<String>
    tenantId Double
    vlanId Double
    vrfId Double
    prefix string
    status string
    Valid values are active, container, reserved and deprecated.
    customFields {[key: string]: string}
    description string
    isPool boolean
    locationId number
    Conflicts with site_id, site_group_id and region_id.
    markUtilized boolean
    prefixId string
    The ID of this resource.
    regionId number
    Conflicts with location_id, site_id and site_group_id.
    roleId number
    siteGroupId number
    Conflicts with location_id, site_id and region_id.
    siteId number
    Conflicts with location_id, site_group_id and region_id.
    tags string[]
    tenantId number
    vlanId number
    vrfId number
    prefix str
    status str
    Valid values are active, container, reserved and deprecated.
    custom_fields Mapping[str, str]
    description str
    is_pool bool
    location_id float
    Conflicts with site_id, site_group_id and region_id.
    mark_utilized bool
    prefix_id str
    The ID of this resource.
    region_id float
    Conflicts with location_id, site_id and site_group_id.
    role_id float
    site_group_id float
    Conflicts with location_id, site_id and region_id.
    site_id float
    Conflicts with location_id, site_group_id and region_id.
    tags Sequence[str]
    tenant_id float
    vlan_id float
    vrf_id float
    prefix String
    status String
    Valid values are active, container, reserved and deprecated.
    customFields Map<String>
    description String
    isPool Boolean
    locationId Number
    Conflicts with site_id, site_group_id and region_id.
    markUtilized Boolean
    prefixId String
    The ID of this resource.
    regionId Number
    Conflicts with location_id, site_id and site_group_id.
    roleId Number
    siteGroupId Number
    Conflicts with location_id, site_id and region_id.
    siteId Number
    Conflicts with location_id, site_group_id and region_id.
    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.
    TagsAlls List<string>
    Id string
    The provider-assigned unique ID for this managed resource.
    TagsAlls []string
    id String
    The provider-assigned unique ID for this managed resource.
    tagsAlls List<String>
    id string
    The provider-assigned unique ID for this managed resource.
    tagsAlls string[]
    id str
    The provider-assigned unique ID for this managed resource.
    tags_alls Sequence[str]
    id String
    The provider-assigned unique ID for this managed resource.
    tagsAlls List<String>

    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,
            location_id: Optional[float] = None,
            mark_utilized: Optional[bool] = None,
            prefix: Optional[str] = None,
            prefix_id: Optional[str] = None,
            region_id: Optional[float] = None,
            role_id: Optional[float] = None,
            site_group_id: Optional[float] = None,
            site_id: Optional[float] = None,
            status: Optional[str] = None,
            tags: Optional[Sequence[str]] = None,
            tags_alls: 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
    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:
    CustomFields Dictionary<string, string>
    Description string
    IsPool bool
    LocationId double
    Conflicts with site_id, site_group_id and region_id.
    MarkUtilized bool
    Prefix string
    PrefixId string
    The ID of this resource.
    RegionId double
    Conflicts with location_id, site_id and site_group_id.
    RoleId double
    SiteGroupId double
    Conflicts with location_id, site_id and region_id.
    SiteId double
    Conflicts with location_id, site_group_id and region_id.
    Status string
    Valid values are active, container, reserved and deprecated.
    Tags List<string>
    TagsAlls List<string>
    TenantId double
    VlanId double
    VrfId double
    CustomFields map[string]string
    Description string
    IsPool bool
    LocationId float64
    Conflicts with site_id, site_group_id and region_id.
    MarkUtilized bool
    Prefix string
    PrefixId string
    The ID of this resource.
    RegionId float64
    Conflicts with location_id, site_id and site_group_id.
    RoleId float64
    SiteGroupId float64
    Conflicts with location_id, site_id and region_id.
    SiteId float64
    Conflicts with location_id, site_group_id and region_id.
    Status string
    Valid values are active, container, reserved and deprecated.
    Tags []string
    TagsAlls []string
    TenantId float64
    VlanId float64
    VrfId float64
    customFields Map<String,String>
    description String
    isPool Boolean
    locationId Double
    Conflicts with site_id, site_group_id and region_id.
    markUtilized Boolean
    prefix String
    prefixId String
    The ID of this resource.
    regionId Double
    Conflicts with location_id, site_id and site_group_id.
    roleId Double
    siteGroupId Double
    Conflicts with location_id, site_id and region_id.
    siteId Double
    Conflicts with location_id, site_group_id and region_id.
    status String
    Valid values are active, container, reserved and deprecated.
    tags List<String>
    tagsAlls List<String>
    tenantId Double
    vlanId Double
    vrfId Double
    customFields {[key: string]: string}
    description string
    isPool boolean
    locationId number
    Conflicts with site_id, site_group_id and region_id.
    markUtilized boolean
    prefix string
    prefixId string
    The ID of this resource.
    regionId number
    Conflicts with location_id, site_id and site_group_id.
    roleId number
    siteGroupId number
    Conflicts with location_id, site_id and region_id.
    siteId number
    Conflicts with location_id, site_group_id and region_id.
    status string
    Valid values are active, container, reserved and deprecated.
    tags string[]
    tagsAlls string[]
    tenantId number
    vlanId number
    vrfId number
    custom_fields Mapping[str, str]
    description str
    is_pool bool
    location_id float
    Conflicts with site_id, site_group_id and region_id.
    mark_utilized bool
    prefix str
    prefix_id str
    The ID of this resource.
    region_id float
    Conflicts with location_id, site_id and site_group_id.
    role_id float
    site_group_id float
    Conflicts with location_id, site_id and region_id.
    site_id float
    Conflicts with location_id, site_group_id and region_id.
    status str
    Valid values are active, container, reserved and deprecated.
    tags Sequence[str]
    tags_alls Sequence[str]
    tenant_id float
    vlan_id float
    vrf_id float
    customFields Map<String>
    description String
    isPool Boolean
    locationId Number
    Conflicts with site_id, site_group_id and region_id.
    markUtilized Boolean
    prefix String
    prefixId String
    The ID of this resource.
    regionId Number
    Conflicts with location_id, site_id and site_group_id.
    roleId Number
    siteGroupId Number
    Conflicts with location_id, site_id and region_id.
    siteId Number
    Conflicts with location_id, site_group_id and region_id.
    status String
    Valid values are active, container, reserved and deprecated.
    tags List<String>
    tagsAlls 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.
    netbox logo
    netbox 4.0.0 published on Thursday, Jun 12, 2025 by e-breuninger