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

netbox.Asn

Explore with Pulumi AI

From the official documentation:

ASN is short for Autonomous System Number. This identifier is used in the BGP protocol to identify which “autonomous system” a particular prefix is originating and transiting through.

The AS number model within NetBox allows you to model some of this real-world relationship.

Example Usage

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

const testRir = new netbox.Rir("testRir", {});
const testAsn = new netbox.Asn("testAsn", {
    asn: 1337,
    rirId: testRir.rirId,
    description: "test",
    comments: "test",
});
Copy
import pulumi
import pulumi_netbox as netbox

test_rir = netbox.Rir("testRir")
test_asn = netbox.Asn("testAsn",
    asn=1337,
    rir_id=test_rir.rir_id,
    description="test",
    comments="test")
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 {
		testRir, err := netbox.NewRir(ctx, "testRir", nil)
		if err != nil {
			return err
		}
		_, err = netbox.NewAsn(ctx, "testAsn", &netbox.AsnArgs{
			Asn:         pulumi.Float64(1337),
			RirId:       testRir.RirId,
			Description: pulumi.String("test"),
			Comments:    pulumi.String("test"),
		})
		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 testRir = new Netbox.Rir("testRir");

    var testAsn = new Netbox.Asn("testAsn", new()
    {
        Asn = 1337,
        RirId = testRir.RirId,
        Description = "test",
        Comments = "test",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.netbox.Rir;
import com.pulumi.netbox.Asn;
import com.pulumi.netbox.AsnArgs;
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 testRir = new Rir("testRir");

        var testAsn = new Asn("testAsn", AsnArgs.builder()
            .asn(1337)
            .rirId(testRir.rirId())
            .description("test")
            .comments("test")
            .build());

    }
}
Copy
resources:
  testRir:
    type: netbox:Rir
  testAsn:
    type: netbox:Asn
    properties:
      asn: 1337
      rirId: ${testRir.rirId}
      description: test
      comments: test
Copy

Create Asn Resource

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

Constructor syntax

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

@overload
def Asn(resource_name: str,
        opts: Optional[ResourceOptions] = None,
        asn: Optional[float] = None,
        rir_id: Optional[float] = None,
        asn_id: Optional[str] = None,
        comments: Optional[str] = None,
        description: Optional[str] = None,
        tags: Optional[Sequence[str]] = None)
func NewAsn(ctx *Context, name string, args AsnArgs, opts ...ResourceOption) (*Asn, error)
public Asn(string name, AsnArgs args, CustomResourceOptions? opts = null)
public Asn(String name, AsnArgs args)
public Asn(String name, AsnArgs args, CustomResourceOptions options)
type: netbox:Asn
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. AsnArgs
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. AsnArgs
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. AsnArgs
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. AsnArgs
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. AsnArgs
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 asnResource = new Netbox.Asn("asnResource", new()
{
    Asn = 0,
    RirId = 0,
    AsnId = "string",
    Comments = "string",
    Description = "string",
    Tags = new[]
    {
        "string",
    },
});
Copy
example, err := netbox.NewAsn(ctx, "asnResource", &netbox.AsnArgs{
	Asn:         pulumi.Float64(0),
	RirId:       pulumi.Float64(0),
	AsnId:       pulumi.String("string"),
	Comments:    pulumi.String("string"),
	Description: pulumi.String("string"),
	Tags: pulumi.StringArray{
		pulumi.String("string"),
	},
})
Copy
var asnResource = new Asn("asnResource", AsnArgs.builder()
    .asn(0)
    .rirId(0)
    .asnId("string")
    .comments("string")
    .description("string")
    .tags("string")
    .build());
Copy
asn_resource = netbox.Asn("asnResource",
    asn=0,
    rir_id=0,
    asn_id="string",
    comments="string",
    description="string",
    tags=["string"])
Copy
const asnResource = new netbox.Asn("asnResource", {
    asn: 0,
    rirId: 0,
    asnId: "string",
    comments: "string",
    description: "string",
    tags: ["string"],
});
Copy
type: netbox:Asn
properties:
    asn: 0
    asnId: string
    comments: string
    description: string
    rirId: 0
    tags:
        - string
Copy

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

Asn This property is required. double
Value for the AS Number record.
RirId This property is required. double
ID for the RIR for the AS Number record.
AsnId string
The ID of this resource.
Comments string
Comments field for the AS Number record.
Description string
Description field for the AS Number record.
Tags List<string>
Asn This property is required. float64
Value for the AS Number record.
RirId This property is required. float64
ID for the RIR for the AS Number record.
AsnId string
The ID of this resource.
Comments string
Comments field for the AS Number record.
Description string
Description field for the AS Number record.
Tags []string
asn This property is required. Double
Value for the AS Number record.
rirId This property is required. Double
ID for the RIR for the AS Number record.
asnId String
The ID of this resource.
comments String
Comments field for the AS Number record.
description String
Description field for the AS Number record.
tags List<String>
asn This property is required. number
Value for the AS Number record.
rirId This property is required. number
ID for the RIR for the AS Number record.
asnId string
The ID of this resource.
comments string
Comments field for the AS Number record.
description string
Description field for the AS Number record.
tags string[]
asn This property is required. float
Value for the AS Number record.
rir_id This property is required. float
ID for the RIR for the AS Number record.
asn_id str
The ID of this resource.
comments str
Comments field for the AS Number record.
description str
Description field for the AS Number record.
tags Sequence[str]
asn This property is required. Number
Value for the AS Number record.
rirId This property is required. Number
ID for the RIR for the AS Number record.
asnId String
The ID of this resource.
comments String
Comments field for the AS Number record.
description String
Description field for the AS Number record.
tags List<String>

Outputs

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

Get an existing Asn 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?: AsnState, opts?: CustomResourceOptions): Asn
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        asn: Optional[float] = None,
        asn_id: Optional[str] = None,
        comments: Optional[str] = None,
        description: Optional[str] = None,
        rir_id: Optional[float] = None,
        tags: Optional[Sequence[str]] = None) -> Asn
func GetAsn(ctx *Context, name string, id IDInput, state *AsnState, opts ...ResourceOption) (*Asn, error)
public static Asn Get(string name, Input<string> id, AsnState? state, CustomResourceOptions? opts = null)
public static Asn get(String name, Output<String> id, AsnState state, CustomResourceOptions options)
resources:  _:    type: netbox:Asn    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:
Asn double
Value for the AS Number record.
AsnId string
The ID of this resource.
Comments string
Comments field for the AS Number record.
Description string
Description field for the AS Number record.
RirId double
ID for the RIR for the AS Number record.
Tags List<string>
Asn float64
Value for the AS Number record.
AsnId string
The ID of this resource.
Comments string
Comments field for the AS Number record.
Description string
Description field for the AS Number record.
RirId float64
ID for the RIR for the AS Number record.
Tags []string
asn Double
Value for the AS Number record.
asnId String
The ID of this resource.
comments String
Comments field for the AS Number record.
description String
Description field for the AS Number record.
rirId Double
ID for the RIR for the AS Number record.
tags List<String>
asn number
Value for the AS Number record.
asnId string
The ID of this resource.
comments string
Comments field for the AS Number record.
description string
Description field for the AS Number record.
rirId number
ID for the RIR for the AS Number record.
tags string[]
asn float
Value for the AS Number record.
asn_id str
The ID of this resource.
comments str
Comments field for the AS Number record.
description str
Description field for the AS Number record.
rir_id float
ID for the RIR for the AS Number record.
tags Sequence[str]
asn Number
Value for the AS Number record.
asnId String
The ID of this resource.
comments String
Comments field for the AS Number record.
description String
Description field for the AS Number record.
rirId Number
ID for the RIR for the AS Number record.
tags List<String>

Package Details

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