Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Network as CodeNew to Visual Studio Code? Get it now.
Network as Code

Network as Code

Network as Code

|
3 installs
| (0) | Free
Network as Code data files and templates in VS Code: the nac-validate checks of your CI as you type, completion, references and a preview of each device's rendered configuration
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Network as Code for VS Code

Network as Code data files and templates in VS Code: the nac-validate checks of your CI as you type, completion, references and a preview of each device's rendered configuration.

The extension works with your project's Terraform module: its schema, defaults and rules, and the nac-validate version it was tested with. What the editor reports is what CI reports.

A misspelt template name is underlined and the device can't be rendered; the quick fix corrects it, the preview shows the device's configuration, and editing a variable updates it

Features

Validation

  • Errors as you type in data files and templates: YAML syntax and schema errors at the key they belong to, and errors that only show once all data files are merged, such as references to names that aren't defined or keys that must be unique across files.
  • Semantic rules of the module on the merged data, if you turn on nac.rules.enabled.
  • Validate as CI does: NAC: Validate with nac-validate runs the nac-validate command line on a project, with its findings in the Problems panel.

The hover of a misspelt template name: the error, what the schema says about the field, and Quick Fix

Editing

  • Completion of keys and values, required keys first. In a new list item, one entry inserts all its required keys at once.
  • Hover: type, limits, allowed values, the default, and a link to the key's page of the data model documentation. On a map's first line, the defaults of the keys it doesn't set.
  • Effective values: for a key set in several data files, the hover says which value is kept once they're merged. NAC: Show Effective Value opens the merged value at the cursor, with the files that set it and the defaults of the keys that aren't set.
  • References: go to definition, find usages, rename (F2) across files, and a code lens with the reference count of each item. Values that refer to an item by name are highlighted differently from other strings.
  • Quick fixes for misspelt keys, values and names, missing required keys, and # nac-validate: ignore[...] comments for rule violations.
  • Outline of each file, with list items named by their primary key (devices › LEAF1), and Go to Symbol in Workspace (Ctrl+T / Cmd+T) for devices, VRFs, interfaces and other named items in all data files.

Completion in a new device: the entry name, url inserts all its required keys  The hover of a key set in two data files: the value that is kept, and the one it overrides

Templates

  • Checks and completion in *.yaml.tftpl templates: the YAML around %{ } and ${ } is checked against the schema, and inside ${ } completion offers variables and functions, with the parameters of a function as you type its arguments.
  • Rendering with the Terraform utils provider, for each device like terraform plan does. NAC: Render Device Configuration previews a device's configuration as you edit, and a code lens at the top of a template says which devices it applies to.
  • Snippets for template directives, and for a module call in .tf files.

Signature help of replace() inside a template expression, and completion of variables, built-ins and functions

Projects

  • Network as Code view in the Explorer: the module, schema, data files, templates and devices of each project, as the extension sees them. Schema Details below it describes the selected key, and NAC: Reveal in Schema finds the key at the cursor.
  • Many projects in one workspace: each project gets its own server, started once you open one of its files. nac.projects.exclude leaves directories such as test fixtures out.

The Network as Code view: the project's module, nac-validate and schema, the key at the cursor selected, and Schema Details below

Requirements

  • A Network as Code Terraform or OpenTofu project: a module call such as netascode/nac-nxos/nxos in a .tf or .tofu file, with its YAML data files.
  • uv, or Python 3.11 or later on PATH. With uv, the extension runs the latest nac-validate release compatible with the version the module was tested with, as the nac CLI does. Without uv, it runs the nac-validate bundled with the extension, which also works offline.
  • For rendering templates: the utils provider, installed by terraform init or tofu init, or downloaded with nac.render.download.

Getting started

  1. Open the folder of your project, or a repository with several projects in subfolders.
  2. Open a data file. The NAC item in the status bar shows the nac-validate version, the schema, and how many data files and rules were found. Click it for the log.

NAC: Get Started opens a walkthrough of the extension.

The module doesn't need to be installed: before terraform init, the schema of the module call is downloaded from the Terraform Registry, and after it, the extension switches to the installed module on its own. If nac-validate can't start or no schema is found, a notification offers what helps, such as installing uv or running terraform init.

Workspace trust

Rules (Python code) and the utils provider (a program) only run in a trusted workspace. In Restricted Mode, data files and templates are still checked against the schema.

With Red Hat YAML

Both extensions can be installed together. This extension takes over the schema checks of the NAC files it checks itself, so errors, completion and hover don't show twice; Red Hat YAML still formats them and checks their YAML syntax.

Known limitations

  • References need a schema that declares them: go to definition, find usages, rename, the reference counts and the highlighting of names only work with a module whose schema marks which fields refer to which items. Some module releases have no such schema yet.
  • One module's data: if a project has several module calls, their data is checked as one set. Terraform keeps each call's data separate.
  • Ansible: projects of the Ansible collections, such as ansible-dc-vxlan, aren't recognised as such. Unless the workspace folder has another project, their files are checked as NAC files of the folder, with the schema from nac.schemaPath, and without the collection's rules.
  • Template functions: completion and signature help offer the functions of utils provider 2.6.0, which may differ from the version you use.

Learn more

The guide has the details: how projects, data files and the schema are found, which nac-validate runs, effective values, templates and rendering, the Projects view, security, and all commands and settings.

Questions, bugs and ideas: GitHub issues.

License

MPL-2.0. The extension includes open source packages under their own licenses: the npm packages listed in dist/ThirdPartyNotices.txt, and the Python packages in bundled/python, with their licenses in their *.dist-info directories.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft