Offline docs (switch to live docs)                          UI-only  CLI-only

Integrating with Terraform for IAC

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

The MAAS Terraform provider enables management of MAAS resources via Terraform's CRUD tool. It focuses on:

Each section 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:

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:


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:

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


The MAAS Terraform provider avails a plethora of resources. Given their number, this guide doesn't cover arguments and attributes in detail. You can explore individual resources like maas_instance, maas_vm_host, maas_vm_host_machine, and maas_machine via their documentation links.

For full details, refer to the Terraform HCL documentation.