This repository contains the source code for the Terraform provider for MAAS, which allows you to manage MAAS (Metal as a Service) resources using Terraform.
- Our latest provider documentation (Canonical/MAAS) - the best place for detailed information about what the provider does and how to use it.
- Provider documentation for v2.2.0 and below (MAAS/MAAS) - no longer maintained.
- Contributing Guide
- Release process
- Changelog
Additional resources:
- Terraform >= 1.4.x
- A MAAS installation
The provider is available from the Terraform Registry. The specified version will be found and installed automatically when specified in the required_providers section of your Terraform configuration file. An example using the latest version is shown below:
terraform {
required_providers {
maas = {
source = "canonical/maas"
version = "~>2.0"
}
}
}
provider "maas" {
api_version = "2.0"
api_key = "YOUR MAAS API KEY"
api_url = "http://<MAAS_SERVER>[:MAAS_PORT]/MAAS"
installation_method = "snap"
}
# Your MAAS Terraform configuration here, for example:
resource "maas_fabric" "test_fabric" {
name = "tf-fabric"
}
where the provider accepts the following config options:
- api_key: MAAS API key.
- api_url: URL for the MAAS API server (eg: http://127.0.0.1:5240/MAAS).
- api_version: MAAS API version used. It is optional and it defaults to
2.0. - installation_method: MAAS installation method used. Optional, defaults to
snap. Valid options:snap, anddeb.
If you want to build the provider from source and (optionally) install it:
-
Clone the repository
-
Enter the repository directory
-
Build the provider with:
make build
-
(Optional): Install the freshly built provider with:
make install
If you're interested in contributing to the provider, please see the Contributing Guide for where to start.
The end to end tests run by the MAAS team's internal CI on a nightly basis against master, and on each PR.
The Terraform Provider for MAAS repository now lives under the Canonical GitHub organisation with a new name github.com/canonical/terraform-provider-maas.
Ensure you are pointing at the new provider name inside your Terraform module(s), which is canonical/maas:
-
Manually update the list of required providers in your Terraform module(s):
terraform { required_providers { maas = { - source = "maas/maas" + source = "canonical/maas" version = "~>2.0" } } } -
Upgrade your provider dependencies to add the
canonical/maasprovider info:terraform init -upgrade
-
Replace the provider reference in your state:
terraform state replace-provider maas/maas canonical/maas
-
Upgrade your provider dependencies to remove the
maas/maasprovider info:terraform init -upgrade
References:
- https://developer.hashicorp.com/terraform/language/files/dependency-lock#dependency-on-a-new-provider
- https://developer.hashicorp.com/terraform/language/files/dependency-lock#providers-that-are-no-longer-required
- https://developer.hashicorp.com/terraform/cli/commands/state/replace-provider
See License.