* docs: improve provider documentation * fix accidentally changed type of stormctrl_ucast_rate * docs: add badges and plans to readme
4.4 KiB
4.4 KiB
layout, page_title, description
| layout | page_title | description |
|---|---|---|
| Provider: UniFi | The UniFi provider enables management and automation of Ubiquiti UniFi network infrastructure through Terraform. |
UniFi Provider
The UniFi provider enables infrastructure-as-code management of Ubiquiti's UniFi network controllers and devices. This provider allows you to automate the configuration and management of your UniFi network infrastructure using Terraform.
Supported Features
The provider supports management of:
- Networks and VLANs
- Wireless Networks (WLANs)
- Firewall Rules and Groups
- Port Forwarding
- DNS Records
- User Management
- Device Configuration
- And more...
Supported Platforms
- UniFi Controller version 6.x and later
- UniFi Dream Machine (UDM)
- UniFi Dream Machine Pro (UDM-Pro)
- UniFi Cloud Gateway (UCG)
- Standard UniFi Controller deployments
Authentication
The provider supports two authentication methods:
- Username/Password Authentication (Traditional method)
- API Key Authentication (Recommended, requires controller version 9.0.108 or later)
!> Hard-coding credentials into any Terraform configuration is not recommended, and risks secret leakage should this file ever be committed to a public version control system.
Security Recommendations
- Use API Key authentication instead of username/password
- Create a dedicated service account for Terraform with appropriate permissions
- Use a Limited Admin role with Local Access Only
- Enable HTTPS and valid SSL certificates for your controller
- Store credentials securely using Terraform variables or environment variables
- Two-factor authentication (2FA) is not supported
Generating an API Key
- Open your Site in UniFi Site Manager
- Click on
Control Plane -> Admins & Users. - Select your Admin user.
- Click
Create API Key. - Add a name for your API Key.
- Copy the key and store it securely, as it will only be displayed once.
- Click
Doneto ensure the key is hashed and securely stored. - Use the API Key 🎉
Example Usage
Using API Key authentication:
provider "unifi" {
api_key = var.api_key # optionally use UNIFI_API_KEY env var
api_url = var.api_url # optionally use UNIFI_API env var
# you may need to allow insecure TLS communications unless you have configured
# certificates for your controller
allow_insecure = var.insecure # optionally use UNIFI_INSECURE env var
# if you are not configuring the default site, you can change the site
# site = "foo" or optionally use UNIFI_SITE env var
}
Using Username/Password authentication:
provider "unifi" {
username = var.username # optionally use UNIFI_USERNAME env var
password = var.password # optionally use UNIFI_PASSWORD env var
api_url = var.api_url # optionally use UNIFI_API env var
# you may need to allow insecure TLS communications unless you have configured
# certificates for your controller
allow_insecure = var.insecure # optionally use UNIFI_INSECURE env var
# if you are not configuring the default site, you can change the site
# site = "foo" or optionally use UNIFI_SITE env var
}
Schema
Optional
allow_insecure(Boolean) Skip verification of TLS certificates of API requests. You may need to set this totrueif you are using your local API without setting up a signed certificate. Can be specified with theUNIFI_INSECUREenvironment variable.api_key(String, Sensitive) API Key for the user accessing the API. Can be specified with theUNIFI_API_KEYenvironment variable. Controller version 9.0.108 or later is required.api_url(String) URL of the controller API. Can be specified with theUNIFI_APIenvironment variable. You should NOT supply the path (/api), the SDK will discover the appropriate paths. This is to support UDM Pro style API paths as well as more standard controller paths.password(String, Sensitive) Password for the user accessing the API. Can be specified with theUNIFI_PASSWORDenvironment variable.site(String) The site in the Unifi controller this provider will manage. Can be specified with theUNIFI_SITEenvironment variable. Default:defaultusername(String) Local user name for the Unifi controller API. Can be specified with theUNIFI_USERNAMEenvironment variable.