published on Monday, Nov 16, 2026 by e-breuninger
published on Monday, Nov 16, 2026 by e-breuninger
A Jinja2 export template for the object types it applies to (extras.exporttemplate).
From the official documentation:
Export templates are used to render arbitrary data from a set of NetBox objects. For example, you might want to automatically generate a network monitoring service configuration from a list of device objects. See the export templates documentation for more information.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as netbox from "@pulumi/netbox";
const test = new netbox.ExportTemplate("test", {
name: "test-export-template",
objectTypes: ["dcim.device"],
templateCode: `{% for obj in queryset %}{{ obj.name }}
{% endfor %}`,
mimeType: "text/csv",
fileName: "test-file",
fileExtension: "csv",
asAttachment: true,
description: "test-description",
});
import pulumi
import pulumi_netbox as netbox
test = netbox.ExportTemplate("test",
name="test-export-template",
object_types=["dcim.device"],
template_code="""{% for obj in queryset %}{{ obj.name }}
{% endfor %}""",
mime_type="text/csv",
file_name="test-file",
file_extension="csv",
as_attachment=True,
description="test-description")
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/netbox/v6/netbox"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := netbox.NewExportTemplate(ctx, "test", &netbox.ExportTemplateArgs{
Name: pulumi.String("test-export-template"),
ObjectTypes: pulumi.StringArray{
pulumi.String("dcim.device"),
},
TemplateCode: pulumi.String("{% for obj in queryset %}{{ obj.name }}\n{% endfor %}"),
MimeType: pulumi.String("text/csv"),
FileName: pulumi.String("test-file"),
FileExtension: pulumi.String("csv"),
AsAttachment: pulumi.Bool(true),
Description: pulumi.String("test-description"),
})
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 test = new Netbox.ExportTemplate("test", new()
{
Name = "test-export-template",
ObjectTypes = new[]
{
"dcim.device",
},
TemplateCode = @"{% for obj in queryset %}{{ obj.name }}
{% endfor %}",
MimeType = "text/csv",
FileName = "test-file",
FileExtension = "csv",
AsAttachment = true,
Description = "test-description",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.netbox.ExportTemplate;
import com.pulumi.netbox.ExportTemplateArgs;
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 test = new ExportTemplate("test", ExportTemplateArgs.builder()
.name("test-export-template")
.objectTypes("dcim.device")
.templateCode("""
{% for obj in queryset %}{{ obj.name }}
{% endfor %} """)
.mimeType("text/csv")
.fileName("test-file")
.fileExtension("csv")
.asAttachment(true)
.description("test-description")
.build());
}
}
resources:
test:
type: netbox:ExportTemplate
properties:
name: test-export-template
objectTypes:
- dcim.device
templateCode: |-
{% for obj in queryset %}{{ obj.name }}
{% endfor %}
mimeType: text/csv
fileName: test-file
fileExtension: csv
asAttachment: true
description: test-description
Example coming soon!
Create ExportTemplate Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new ExportTemplate(name: string, args: ExportTemplateArgs, opts?: CustomResourceOptions);@overload
def ExportTemplate(resource_name: str,
args: ExportTemplateArgs,
opts: Optional[ResourceOptions] = None)
@overload
def ExportTemplate(resource_name: str,
opts: Optional[ResourceOptions] = None,
object_types: Optional[Sequence[str]] = None,
template_code: Optional[str] = None,
as_attachment: Optional[bool] = None,
description: Optional[str] = None,
environment_params: Optional[str] = None,
file_extension: Optional[str] = None,
file_name: Optional[str] = None,
mime_type: Optional[str] = None,
name: Optional[str] = None,
owner_id: Optional[float] = None)func NewExportTemplate(ctx *Context, name string, args ExportTemplateArgs, opts ...ResourceOption) (*ExportTemplate, error)public ExportTemplate(string name, ExportTemplateArgs args, CustomResourceOptions? opts = null)
public ExportTemplate(String name, ExportTemplateArgs args)
public ExportTemplate(String name, ExportTemplateArgs args, CustomResourceOptions options)
type: netbox:ExportTemplate
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
resource "netbox_export_template" "name" {
# resource properties
}Parameters
- name string
- The unique name of the resource.
- args ExportTemplateArgs
- 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 ExportTemplateArgs
- 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 ExportTemplateArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ExportTemplateArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args ExportTemplateArgs
- 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 exportTemplateResource = new Netbox.ExportTemplate("exportTemplateResource", new()
{
ObjectTypes = new[]
{
"string",
},
TemplateCode = "string",
AsAttachment = false,
Description = "string",
EnvironmentParams = "string",
FileExtension = "string",
FileName = "string",
MimeType = "string",
Name = "string",
OwnerId = 0.0,
});
example, err := netbox.NewExportTemplate(ctx, "exportTemplateResource", &netbox.ExportTemplateArgs{
ObjectTypes: pulumi.StringArray{
pulumi.String("string"),
},
TemplateCode: pulumi.String("string"),
AsAttachment: pulumi.Bool(false),
Description: pulumi.String("string"),
EnvironmentParams: pulumi.String("string"),
FileExtension: pulumi.String("string"),
FileName: pulumi.String("string"),
MimeType: pulumi.String("string"),
Name: pulumi.String("string"),
OwnerId: pulumi.Float64(0),
})
resource "netbox_export_template" "exportTemplateResource" {
lifecycle {
create_before_destroy = true
}
object_types = ["string"]
template_code = "string"
as_attachment = false
description = "string"
environment_params = "string"
file_extension = "string"
file_name = "string"
mime_type = "string"
name = "string"
owner_id = 0
}
var exportTemplateResource = new ExportTemplate("exportTemplateResource", ExportTemplateArgs.builder()
.objectTypes("string")
.templateCode("string")
.asAttachment(false)
.description("string")
.environmentParams("string")
.fileExtension("string")
.fileName("string")
.mimeType("string")
.name("string")
.ownerId(0.0)
.build());
export_template_resource = netbox.ExportTemplate("exportTemplateResource",
object_types=["string"],
template_code="string",
as_attachment=False,
description="string",
environment_params="string",
file_extension="string",
file_name="string",
mime_type="string",
name="string",
owner_id=float(0))
const exportTemplateResource = new netbox.ExportTemplate("exportTemplateResource", {
objectTypes: ["string"],
templateCode: "string",
asAttachment: false,
description: "string",
environmentParams: "string",
fileExtension: "string",
fileName: "string",
mimeType: "string",
name: "string",
ownerId: 0,
});
type: netbox:ExportTemplate
properties:
asAttachment: false
description: string
environmentParams: string
fileExtension: string
fileName: string
mimeType: string
name: string
objectTypes:
- string
ownerId: 0
templateCode: string
ExportTemplate 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 ExportTemplate resource accepts the following input properties:
- Object
Types List<string> - Object types the template can export, as app-labelled content types (dcim.device).
- Template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- As
Attachment bool - Download the rendered output as a file instead of displaying it.
- Description string
- Environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- File
Extension string - Extension appended to the file name, e.g. csv.
- File
Name string - File name of the rendered output, without extension.
- Mime
Type string - MIME type of the rendered output, e.g. text/csv.
- Name string
- Owner
Id double - Id of the owner the object is assigned to.
- Object
Types []string - Object types the template can export, as app-labelled content types (dcim.device).
- Template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- As
Attachment bool - Download the rendered output as a file instead of displaying it.
- Description string
- Environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- File
Extension string - Extension appended to the file name, e.g. csv.
- File
Name string - File name of the rendered output, without extension.
- Mime
Type string - MIME type of the rendered output, e.g. text/csv.
- Name string
- Owner
Id float64 - Id of the owner the object is assigned to.
- object_
types list(string) - Object types the template can export, as app-labelled content types (dcim.device).
- template_
code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- as_
attachment bool - Download the rendered output as a file instead of displaying it.
- description string
- environment_
params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- file_
extension string - Extension appended to the file name, e.g. csv.
- file_
name string - File name of the rendered output, without extension.
- mime_
type string - MIME type of the rendered output, e.g. text/csv.
- name string
- owner_
id number - Id of the owner the object is assigned to.
- object
Types List<String> - Object types the template can export, as app-labelled content types (dcim.device).
- template
Code String - Jinja2 template code; the queryset is available as {{ queryset }}.
- as
Attachment Boolean - Download the rendered output as a file instead of displaying it.
- description String
- environment
Params String - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- file
Extension String - Extension appended to the file name, e.g. csv.
- file
Name String - File name of the rendered output, without extension.
- mime
Type String - MIME type of the rendered output, e.g. text/csv.
- name String
- owner
Id Double - Id of the owner the object is assigned to.
- object
Types string[] - Object types the template can export, as app-labelled content types (dcim.device).
- template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- as
Attachment boolean - Download the rendered output as a file instead of displaying it.
- description string
- environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- file
Extension string - Extension appended to the file name, e.g. csv.
- file
Name string - File name of the rendered output, without extension.
- mime
Type string - MIME type of the rendered output, e.g. text/csv.
- name string
- owner
Id number - Id of the owner the object is assigned to.
- object_
types Sequence[str] - Object types the template can export, as app-labelled content types (dcim.device).
- template_
code str - Jinja2 template code; the queryset is available as {{ queryset }}.
- as_
attachment bool - Download the rendered output as a file instead of displaying it.
- description str
- environment_
params str - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- file_
extension str - Extension appended to the file name, e.g. csv.
- file_
name str - File name of the rendered output, without extension.
- mime_
type str - MIME type of the rendered output, e.g. text/csv.
- name str
- owner_
id float - Id of the owner the object is assigned to.
- object
Types List<String> - Object types the template can export, as app-labelled content types (dcim.device).
- template
Code String - Jinja2 template code; the queryset is available as {{ queryset }}.
- as
Attachment Boolean - Download the rendered output as a file instead of displaying it.
- description String
- environment
Params String - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- file
Extension String - Extension appended to the file name, e.g. csv.
- file
Name String - File name of the rendered output, without extension.
- mime
Type String - MIME type of the rendered output, e.g. text/csv.
- name String
- owner
Id Number - Id of the owner the object is assigned to.
Outputs
All input properties are implicitly available as output properties. Additionally, the ExportTemplate resource produces the following output properties:
- Created string
- Export
Template doubleId - NetBox id.
- Id string
- The provider-assigned unique ID for this managed resource.
- Last
Updated string - Url string
- Created string
- Export
Template float64Id - NetBox id.
- Id string
- The provider-assigned unique ID for this managed resource.
- Last
Updated string - Url string
- created string
- export_
template_ numberid - NetBox id.
- id string
- The provider-assigned unique ID for this managed resource.
- last_
updated string - url string
- created String
- export
Template DoubleId - NetBox id.
- id String
- The provider-assigned unique ID for this managed resource.
- last
Updated String - url String
- created string
- export
Template numberId - NetBox id.
- id string
- The provider-assigned unique ID for this managed resource.
- last
Updated string - url string
- created str
- export_
template_ floatid - NetBox id.
- id str
- The provider-assigned unique ID for this managed resource.
- last_
updated str - url str
- created String
- export
Template NumberId - NetBox id.
- id String
- The provider-assigned unique ID for this managed resource.
- last
Updated String - url String
Look up Existing ExportTemplate Resource
Get an existing ExportTemplate 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?: ExportTemplateState, opts?: CustomResourceOptions): ExportTemplate@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
as_attachment: Optional[bool] = None,
created: Optional[str] = None,
description: Optional[str] = None,
environment_params: Optional[str] = None,
export_template_id: Optional[float] = None,
file_extension: Optional[str] = None,
file_name: Optional[str] = None,
last_updated: Optional[str] = None,
mime_type: Optional[str] = None,
name: Optional[str] = None,
object_types: Optional[Sequence[str]] = None,
owner_id: Optional[float] = None,
template_code: Optional[str] = None,
url: Optional[str] = None) -> ExportTemplatefunc GetExportTemplate(ctx *Context, name string, id IDInput, state *ExportTemplateState, opts ...ResourceOption) (*ExportTemplate, error)public static ExportTemplate Get(string name, Input<string> id, ExportTemplateState? state, CustomResourceOptions? opts = null)public static ExportTemplate get(String name, Output<String> id, ExportTemplateState state, CustomResourceOptions options)resources: existingExportTemplate: type: netbox:ExportTemplate get: id: ${id}import {
to = netbox_export_template.example
id = "${id}"
}
- name string
- The unique name of the resulting resource.
- id Input<ID>
- The unique provider ID of the resource to look up.
- state ExportTemplateState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resulting resource.
- id str
- The unique provider ID of the resource to look up.
- 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 resulting resource.
- id IDInput
- The unique provider ID of the resource to look up.
- state ExportTemplateState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resulting resource.
- id Input<string>
- The unique provider ID of the resource to look up.
- state ExportTemplateState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resulting resource.
- id Output<String>
- The unique provider ID of the resource to look up.
- state ExportTemplateState
- Known property values the provider needs, along with the ID, to find the resource. Usually not required.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
- As
Attachment bool - Download the rendered output as a file instead of displaying it.
- Created string
- Description string
- Environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- Export
Template doubleId - NetBox id.
- File
Extension string - Extension appended to the file name, e.g. csv.
- File
Name string - File name of the rendered output, without extension.
- Last
Updated string - Mime
Type string - MIME type of the rendered output, e.g. text/csv.
- Name string
- Object
Types List<string> - Object types the template can export, as app-labelled content types (dcim.device).
- Owner
Id double - Id of the owner the object is assigned to.
- Template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- Url string
- As
Attachment bool - Download the rendered output as a file instead of displaying it.
- Created string
- Description string
- Environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- Export
Template float64Id - NetBox id.
- File
Extension string - Extension appended to the file name, e.g. csv.
- File
Name string - File name of the rendered output, without extension.
- Last
Updated string - Mime
Type string - MIME type of the rendered output, e.g. text/csv.
- Name string
- Object
Types []string - Object types the template can export, as app-labelled content types (dcim.device).
- Owner
Id float64 - Id of the owner the object is assigned to.
- Template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- Url string
- as_
attachment bool - Download the rendered output as a file instead of displaying it.
- created string
- description string
- environment_
params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- export_
template_ numberid - NetBox id.
- file_
extension string - Extension appended to the file name, e.g. csv.
- file_
name string - File name of the rendered output, without extension.
- last_
updated string - mime_
type string - MIME type of the rendered output, e.g. text/csv.
- name string
- object_
types list(string) - Object types the template can export, as app-labelled content types (dcim.device).
- owner_
id number - Id of the owner the object is assigned to.
- template_
code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- url string
- as
Attachment Boolean - Download the rendered output as a file instead of displaying it.
- created String
- description String
- environment
Params String - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- export
Template DoubleId - NetBox id.
- file
Extension String - Extension appended to the file name, e.g. csv.
- file
Name String - File name of the rendered output, without extension.
- last
Updated String - mime
Type String - MIME type of the rendered output, e.g. text/csv.
- name String
- object
Types List<String> - Object types the template can export, as app-labelled content types (dcim.device).
- owner
Id Double - Id of the owner the object is assigned to.
- template
Code String - Jinja2 template code; the queryset is available as {{ queryset }}.
- url String
- as
Attachment boolean - Download the rendered output as a file instead of displaying it.
- created string
- description string
- environment
Params string - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- export
Template numberId - NetBox id.
- file
Extension string - Extension appended to the file name, e.g. csv.
- file
Name string - File name of the rendered output, without extension.
- last
Updated string - mime
Type string - MIME type of the rendered output, e.g. text/csv.
- name string
- object
Types string[] - Object types the template can export, as app-labelled content types (dcim.device).
- owner
Id number - Id of the owner the object is assigned to.
- template
Code string - Jinja2 template code; the queryset is available as {{ queryset }}.
- url string
- as_
attachment bool - Download the rendered output as a file instead of displaying it.
- created str
- description str
- environment_
params str - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- export_
template_ floatid - NetBox id.
- file_
extension str - Extension appended to the file name, e.g. csv.
- file_
name str - File name of the rendered output, without extension.
- last_
updated str - mime_
type str - MIME type of the rendered output, e.g. text/csv.
- name str
- object_
types Sequence[str] - Object types the template can export, as app-labelled content types (dcim.device).
- owner_
id float - Id of the owner the object is assigned to.
- template_
code str - Jinja2 template code; the queryset is available as {{ queryset }}.
- url str
- as
Attachment Boolean - Download the rendered output as a file instead of displaying it.
- created String
- description String
- environment
Params String - Parameters for the Jinja2 environment as JSON text (use jsonencode()).
- export
Template NumberId - NetBox id.
- file
Extension String - Extension appended to the file name, e.g. csv.
- file
Name String - File name of the rendered output, without extension.
- last
Updated String - mime
Type String - MIME type of the rendered output, e.g. text/csv.
- name String
- object
Types List<String> - Object types the template can export, as app-labelled content types (dcim.device).
- owner
Id Number - Id of the owner the object is assigned to.
- template
Code String - Jinja2 template code; the queryset is available as {{ queryset }}.
- url String
Import
In Terraform v1.5.0 and later, the import block can be used with the id attribute, for example:
terraform
import {
to = netbox_export_template.test
id = “123”
}
The pulumi import command can be used, for example:
$ pulumi import netbox:index/exportTemplate:ExportTemplate test 123
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- netbox e-breuninger/terraform-provider-netbox
- License
- Notes
- This Pulumi package is based on the
netboxTerraform Provider.
published on Monday, Nov 16, 2026 by e-breuninger