Reference: Terraform

Errors or typos? Topics missing? Hard to read? Let us know.

To use MAAS with Terraform, a provider is available. This guide gives an overview of data sources and resources accessible via this provider, without delving into the mechanics of Terraform or the MAAS Terraform provider.

The MAAS Terraform provider enables management of MAAS resources via Terraform’s CRUD tool. Each section in this document provides definitions and usage examples. For more about Terraform, consult the Terraform documentation or various available tutorials.

API linkages

To connect MAAS with Terraform, you’ll need both a standard HCL provider block and a provider API block. The former requires at least:

  • A source element: “maas/maas”.
  • A version element: “~>1.0”.

Here’s what the provider block might look like:

terraform {
  required_providers {
    maas = {
      source  = "maas/maas"
      version = "~>1.0"

The provider API block includes credentials for MAAS access:

  • API version
  • API key


provider "maas" {
  api_version = "2.0"
  api_key = "<YOUR API KEY>"
  api_url = ""

Data sources

The MAAS Terraform provider offers three main data sources focused on networking:

  • Fabrics
  • Subnets
  • VLANs

Each data source comes with an HCL block that manages its corresponding MAAS element.


The fabric data source reveals minimal details, usually the fabric ID:

data "maas_fabric" "default" {
  name = "maas"


The subnet data source provides extensive attributes for an existing MAAS subnet. To declare one:

data "maas_subnet" "vid10" {
  cidr = ""


The VLAN data source focuses on an existing MAAS VLAN. For instance:

data "maas_vlan" "vid10" {
  fabric =
  vlan = 10


For full details, refer to the Terraform HCL documentation^.

Last updated 2 months ago.