### Terraform Static Route Examples Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/static_route.md Demonstrates how to configure static routes using the unifi_static_route resource in Terraform. It covers 'nexthop', 'blackhole', and 'interface' route types, showcasing the necessary parameters for each. This resource is part of the terraform-provider-unifi. ```terraform resource "unifi_static_route" "nexthop" { type = "nexthop-route" network = "172.17.0.0/16" name = "basic nexthop" distance = 1 next_hop = "172.16.0.1" } resource "unifi_static_route" "blackhole" { type = "blackhole" network = var.blackhole_cidr name = "blackhole traffice to cidr" distance = 1 } resource "unifi_static_route" "interface" { type = "interface-route" network = var.wan2_cidr name = "send traffic over wan2" distance = 1 interface = "WAN2" } ``` -------------------------------- ### Create unifi_setting_mgmt Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/setting_mgmt.md Example usage of the `unifi_setting_mgmt` resource to configure site management settings. It requires associating with an existing `unifi_site` resource and can set options like automatic firmware upgrades. ```terraform resource "unifi_site" "example" { description = "example" } resource "unifi_setting_mgmt" "example" { site = unifi_site.example.name auto_upgrade = true } ``` -------------------------------- ### Create UniFi Firewall Rule Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/firewall_rule.md This example demonstrates how to create a basic firewall rule on a UniFi gateway using Terraform. It defines the rule's name, action, ruleset, index, protocol, and destination address. The `unifi_firewall_rule` resource requires the `name`, `action`, `rule_index`, and `ruleset` arguments. ```Terraform variable "ip_address" { type = string } resource "unifi_firewall_rule" "drop_all" { name = "drop all" action = "drop" ruleset = "LAN_IN" rule_index = 2011 protocol = "all" dst_address = var.ip_address } ``` -------------------------------- ### Terraform Example: Create a WAN Network Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/network.md This Terraform code defines a `unifi_network` resource to configure a WAN (Wide Area Network) connection. It includes details for PPPoE authentication, IP address, Quality of Service (QoS) settings, and credentials. Sensitive information like passwords should be managed securely. ```terraform resource "unifi_network" "wan" { name = "wan" purpose = "wan" wan_networkgroup = "WAN" wan_type = "pppoe" wan_ip = "192.168.1.1" wan_egress_qos = 1 wan_username = "username" x_wan_password = "password" } ``` -------------------------------- ### Example Usage for unifi_ap_group Data Source Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/ap_group.md This example demonstrates how to use the unifi_ap_group data source to retrieve the default AP group. It requires no specific inputs if you intend to use the default group. The output is the ID of the retrieved AP group. ```terraform data "unifi_ap_group" "default" { } ``` -------------------------------- ### Import UniFi Firewall Rule Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/firewall_rule.md This example shows how to import an existing UniFi firewall rule into Terraform management. The import command requires the resource name and the firewall rule's ID obtained from the UniFi controller API or UI. ```shell # import using the ID from the controller API/UI terraform import unifi_firewall_rule.my_rule 5f7080eb6b8969064f80494f ``` -------------------------------- ### Terraform Example: Create a VLAN Network Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/network.md This Terraform code defines a `unifi_network` resource to create a corporate VLAN network. It specifies the network name, purpose, subnet details, DHCP range, and VLAN ID. Ensure the `vlan_id` variable is defined elsewhere. ```terraform resource "unifi_network" "vlan" { name = "wifi-vlan" purpose = "corporate" subnet = "10.0.0.1/24" vlan_id = var.vlan_id dhcp_start = "10.0.0.6" dhcp_stop = "10.0.0.254" dhcp_enabled = true } ``` -------------------------------- ### Retrieve Unifi Network Data by ID from User Record Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/network.md This Terraform example shows how to retrieve Unifi network data by ID, which is dynamically obtained from a user record. It first uses the 'unifi_user' data source to get user details (including network ID) and then uses the 'unifi_network' data source with the retrieved 'network_id'. ```terraform #retrieve network data from user record data "unifi_user" "my_device" { mac = "01:23:45:67:89:ab" } data "unifi_network" "my_network" { id = data.unifi_user.my_device.network_id } ``` -------------------------------- ### Terraform Unifi Port Profile Creation with VLAN and PoE Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/port_profile.md This example demonstrates how to create a UniFi port profile using Terraform. It configures a port to use a specific VLAN and sets the PoE mode to 'off'. The `unifi_network` resource is a prerequisite, defining the VLAN that the port profile will utilize. ```Terraform variable "vlan_id" { default = 10 } resource "unifi_network" "vlan" { name = "wifi-vlan" purpose = "corporate" subnet = "10.0.0.1/24" vlan_id = var.vlan_id dhcp_start = "10.0.0.6" dhcp_stop = "10.0.0.254" dhcp_enabled = true } resource "unifi_port_profile" "poe_disabled" { name = "POE Disabled" native_networkconf_id = unifi_network.vlan.id poe_mode = "off" } ``` -------------------------------- ### Create a Unifi Site Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/site.md This snippet demonstrates how to define and create a Unifi site resource using Terraform. It requires a description for the site and outputs the site ID, name, and description. ```terraform resource "unifi_site" "mysite" { description = "mysite" } ``` -------------------------------- ### Import a Unifi Site Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/site.md This snippet shows how to import an existing Unifi site into Terraform management. You can import using either the site's API/UI ID or its short ID (name). ```shell # import using the API/UI ID terraform import unifi_site.mysite 5fe6261995fe130013456a36 ``` ```shell # import using the name (short ID) terraform import unifi_site.mysite vq98kwez ``` -------------------------------- ### Terraform Import for unifi_wlan Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/wlan.md Demonstrates how to import an existing unifi_wlan resource into Terraform state management. Two import syntaxes are provided: one for the default provider-configured site and another for specifying a different site. ```shell # import from provider configured site terraform import unifi_wlan.mywlan 5dc28e5e9106d105bdc87217 # import from another site terraform import unifi_wlan.mywlan bfa2l6i7:5dc28e5e9106d105bdc87217 ``` -------------------------------- ### Import Unifi Network Resource (Terraform) Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/network.md Demonstrates how to import an existing Unifi network resource into Terraform state. Supports importing by provider configuration, by site-specific ID, or by network name. ```shell # import from provider configured site terraform import unifi_network.mynetwork 5dc28e5e9106d105bdc87217 ``` ```shell # import from another site terraform import unifi_network.mynetwork bfa2l6i7:5dc28e5e9106d105bdc87217 ``` ```shell # import network by name terraform import unifi_network.mynetwork name=LAN ``` -------------------------------- ### Manage DNS Record - Terraform Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/dns_record.md This Terraform code defines a `unifi_dns_record` resource. It specifies the name, enablement status, port, priority, record type, TTL, and value for a DNS record. Optional parameters like 'site' and 'weight' can also be configured. ```terraform resource "unifi_dns_record" "test" { name = "my-network" enabled = true port = 0 priority = 10 record_type = "A" ttl = 300 value = "my-network.example.com" } ``` -------------------------------- ### Network Configuration Parameters Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/network.md This section details the read-only parameters available for Unifi network configurations. These parameters describe the current state of network settings like DHCP, IPv6, and WAN configurations. ```APIDOC ## Network Configuration Read-Only Parameters ### Description This endpoint provides details on the configurable parameters for Unifi networks. ### Method GET ### Endpoint /api/network/config ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **dhcp_dns** (List of String) - IPv4 addresses for the DNS server to be returned from the DHCP server. - **dhcp_enabled** (Boolean) - Whether DHCP is enabled or not on this network. - **dhcp_lease** (Number) - Lease time for DHCP addresses. - **dhcp_start** (String) - The IPv4 address where the DHCP range of addresses starts. - **dhcp_stop** (String) - The IPv4 address where the DHCP range of addresses stops. - **dhcp_v6_dns** (List of String) - Specifies the IPv6 addresses for the DNS server to be returned from the DHCP server. Used if `dhcp_v6_dns_auto` is set to `false`. - **dhcp_v6_dns_auto** (Boolean) - Specifies DNS source to propagate. If set `false` the entries in `dhcp_v6_dns` are used, the upstream entries otherwise. - **dhcp_v6_enabled** (Boolean) - Enable stateful DHCPv6 for static configuration. - **dhcp_v6_lease** (Number) - Specifies the lease time for DHCPv6 addresses. - **dhcp_v6_start** (String) - Start address of the DHCPv6 range. Used in static DHCPv6 configuration. - **dhcp_v6_stop** (String) - End address of the DHCPv6 range. Used in static DHCPv6 configuration. - **dhcpd_boot_enabled** (Boolean) - Toggles on the DHCP boot options. Will be set to true if `dhcpd_boot_filename` and `dhcpd_boot_server` are set. - **dhcpd_boot_filename** (String) - The file to PXE boot from on the `dhcpd_boot_server`. - **dhcpd_boot_server** (String) - IPv4 address of a TFTP server to network boot from. - **domain_name** (String) - The domain name of this network. - **igmp_snooping** (Boolean) - Specifies whether IGMP snooping is enabled or not. - **ipv6_interface_type** (String) - Specifies which type of IPv6 connection to use. Must be one of either `static`, `pd`, or `none`. - **ipv6_pd_interface** (String) - Specifies which WAN interface to use for IPv6 PD. Must be one of either `wan` or `wan2`. - **ipv6_pd_prefixid** (String) - Specifies the IPv6 Prefix ID. - **ipv6_pd_start** (String) - Start address of the DHCPv6 range. Used if `ipv6_interface_type` is set to `pd`. - **ipv6_pd_stop** (String) - End address of the DHCPv6 range. Used if `ipv6_interface_type` is set to `pd`. - **ipv6_ra_enable** (Boolean) - Specifies whether to enable router advertisements or not. - **ipv6_ra_preferred_lifetime** (Number) - Lifetime in which the address can be used. Address becomes deprecated afterwards. Must be lower than or equal to `ipv6_ra_valid_lifetime`. - **ipv6_ra_priority** (String) - IPv6 router advertisement priority. Must be one of either `high`, `medium`, or `low`. - **ipv6_ra_valid_lifetime** (Number) - Total lifetime in which the address can be used. Must be equal to or greater than `ipv6_ra_preferred_lifetime`. - **ipv6_static_subnet** (String) - Specifies the static IPv6 subnet (when `ipv6_interface_type` is 'static'). - **multicast_dns** (Boolean) - Specifies whether Multicast DNS (mDNS) is enabled or not on the network (Controller >=v7). - **network_group** (String) - The group of the network. - **purpose** (String) - The purpose of the network. One of `corporate`, `guest`, `wan`, or `vlan-only`. - **subnet** (String) - The subnet of the network (CIDR address). - **vlan_id** (Number) - The VLAN ID of the network. - **wan_dhcp_v6_pd_size** (Number) - Specifies the IPv6 prefix size to request from ISP. Must be a number between 48 and 64. - **wan_dns** (List of String) - DNS servers IPs of the WAN. - **wan_egress_qos** (Number) - Specifies the WAN egress quality of service. - **wan_gateway** (String) - The IPv4 gateway of the WAN. - **wan_gateway_v6** (String) - The IPv6 gateway of the WAN. - **wan_ip** (String) - The IPv4 address of the WAN. - **wan_ipv6** (String) - The IPv6 address of the WAN. - **wan_netmask** (String) - The IPv4 netmask of the WAN. - **wan_networkgroup** (String) - Specifies the WAN network group. One of either `WAN`, `WAN2` or `WAN_LTE_FAILOVER`. - **wan_prefixlen** (Number) - The IPv6 prefix length of the WAN. Must be between 1 and 128. - **wan_type** (String) - Specifies the IPV4 WAN connection type. One of either `disabled`, `static`, `dhcp`, or `pppoe`. - **wan_type_v6** (String) - Specifies the IPV6 WAN connection type. Must be one of either `disabled`, `static`, or `dhcpv6`. - **wan_username** (String) - Specifies the IPV4 WAN username. - **x_wan_password** (String) - Specifies the IPV4 WAN password. #### Response Example ```json { "dhcp_dns": [ "8.8.8.8" ], "dhcp_enabled": true, "dhcp_lease": 86400, "dhcp_start": "192.168.1.100", "dhcp_stop": "192.168.1.200", "dhcp_v6_dns": [], "dhcp_v6_dns_auto": true, "dhcp_v6_enabled": false, "dhcp_v6_lease": 86400, "dhcp_v6_start": "fd00::100", "dhcp_v6_stop": "fd00::200", "dhcpd_boot_enabled": false, "dhcpd_boot_filename": null, "dhcpd_boot_server": null, "domain_name": "example.local", "igmp_snooping": true, "ipv6_interface_type": "none", "ipv6_pd_interface": null, "ipv6_pd_prefixid": null, "ipv6_pd_start": null, "ipv6_pd_stop": null, "ipv6_ra_enable": false, "ipv6_ra_preferred_lifetime": 1800, "ipv6_ra_priority": "medium", "ipv6_ra_valid_lifetime": 3600, "ipv6_static_subnet": null, "multicast_dns": false, "network_group": "default", "purpose": "corporate", "subnet": "192.168.1.0/24", "vlan_id": 1, "wan_dhcp_v6_pd_size": 64, "wan_dns": [ "8.8.8.8" ], "wan_egress_qos": 10000, "wan_gateway": "192.168.1.1", "wan_gateway_v6": null, "wan_ip": "192.168.1.10", "wan_ipv6": null, "wan_netmask": "255.255.255.0", "wan_networkgroup": "WAN", "wan_prefixlen": null, "wan_type": "dhcp", "wan_type_v6": "disabled", "wan_username": null, "x_wan_password": null } ``` ``` -------------------------------- ### Terraform Resource for unifi_user Management Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/user.md This Terraform resource defines and manages a network user (client) within the UniFi controller. It allows for specifying the user's MAC address, name, and optional configurations like a fixed IP, network association, and notes. The resource supports managing existing users or taking over control of them. Dependencies include the `terraform-provider-unifi`. ```terraform resource "unifi_user" "test" { mac = "01:23:45:67:89:AB" name = "some client" note = "my note" fixed_ip = "10.0.0.50" network_id = unifi_network.my_vlan.id } ``` -------------------------------- ### Manage UniFi Device Configuration Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/device.md Configures a UniFi device, specifying its name, MAC address, and port overrides. It also supports controlling adoption and forget behavior on destroy. This resource requires the MAC address for identifying the device. ```terraform data "unifi_port_profile" "disabled" { # look up the built-in disabled port profile name = "Disabled" } resource "unifi_port_profile" "poe" { name = "poe" forward = "customize" native_networkconf_id = var.native_network_id tagged_networkconf_ids = [ var.some_vlan_network_id, ] poe_mode = "auto" } resource "unifi_device" "us_24_poe" { # optionally specify MAC address to skip manually importing # manual import is the safest way to add a device mac = "01:23:45:67:89:AB" name = "Switch with POE" port_override { number = 1 name = "port w/ poe" port_profile_id = unifi_port_profile.poe.id } port_override { number = 2 name = "disabled" port_profile_id = data.unifi_port_profile.disabled.id } # port aggregation for ports 11 and 12 port_override { number = 11 op_mode = "aggregate" aggregate_num_ports = 2 } } ``` -------------------------------- ### Manage Dynamic DNS Configuration Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/dynamic_dns.md This Terraform resource configures dynamic DNS settings for a specified service. It requires the hostname and service provider, and optionally accepts server details, login credentials, and interface settings. The password is treated as sensitive. ```terraform resource "unifi_dynamic_dns" "test" { service = "dyndns" host_name = "my-network.example.com" server = "domains.google.com" login = var.dns_login password = var.dns_password } ``` -------------------------------- ### Create Firewall Address Group - Terraform Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/firewall_group.md Defines a firewall address group named 'can-print' using Terraform. It takes a list of IP addresses as members, which can be dynamically provided via variables. This group can then be referenced in `unifi_firewall_rule` resources. ```terraform variable "laptop_ips" { type = list(string) } resource "unifi_firewall_group" "can_print" { name = "can-print" type = "address-group" members = var.laptop_ips } ``` -------------------------------- ### Unifi Provider Configuration Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/index.md This snippet shows how to configure the Unifi provider in Terraform. It includes essential parameters like username, password, API URL, and TLS settings. Environment variables can be used as alternatives for these parameters. It also mentions the option to specify a different site for management. ```terraform 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 } ``` -------------------------------- ### unifi_radius_profile Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/radius_profile.md Manages RADIUS profiles, including authentication and accounting server configurations. ```APIDOC ## unifi_radius_profile Resource ### Description Manages RADIUS profiles, allowing configuration of authentication and accounting servers, and related settings like VLANs and interim updates. ### Method Not applicable (Terraform resource) ### Endpoint Not applicable (Terraform resource) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (String) - Required - The name of the profile. - **accounting_enabled** (Boolean) - Optional - Specifies whether to use RADIUS accounting. Defaults to `false`. - **acct_server** (Block List) - Optional - RADIUS accounting servers. (see below for nested schema) - **auth_server** (Block List) - Optional - RADIUS authentication servers. (see below for nested schema) - **interim_update_enabled** (Boolean) - Optional - Specifies whether to use interim_update. Defaults to `false`. - **interim_update_interval** (Number) - Optional - Specifies interim_update interval. Defaults to `3600`. - **site** (String) - Optional - The name of the site to associate the settings with. - **use_usg_acct_server** (Boolean) - Optional - Specifies whether to use usg as a RADIUS accounting server. Defaults to `false`. - **use_usg_auth_server** (Boolean) - Optional - Specifies whether to use usg as a RADIUS authentication server. Defaults to `false`. - **vlan_enabled** (Boolean) - Optional - Specifies whether to use vlan on wired connections. Defaults to `false`. - **vlan_wlan_mode** (String) - Optional - Specifies whether to use vlan on wireless connections. Must be one of `disabled`, `optional`, or `required`. Defaults to ``. ### Nested Schema for `acct_server` - **ip** (String) - Required - IP address of accounting service server. - **xsecret** (String, Sensitive) - Required - RADIUS secret. - **port** (Number) - Optional - Port of accounting service. Defaults to `1813`. ### Nested Schema for `auth_server` - **ip** (String) - Required - IP address of authentication service server. - **xsecret** (String, Sensitive) - Required - RADIUS secret. - **port** (Number) - Optional - Port of authentication service. Defaults to `1812`. ### Request Example ```json { "name": "MyRADIUSProfile", "auth_server": [ { "ip": "192.168.1.100", "port": 1812, "xsecret": "verysecret" } ], "accounting_enabled": true, "site": "Default" } ``` ### Response #### Success Response (200) - **id** (String) - The ID of the settings. #### Response Example ```json { "id": "60c72b2f9b1d8b001a8a4c12", "name": "MyRADIUSProfile", "auth_server": [ { "ip": "192.168.1.100", "port": 1812, "xsecret": "verysecret" } ], "accounting_enabled": true, "site": "Default" } ``` ``` -------------------------------- ### Apply Firewall Rule to Multiple Sites - Terraform Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/guides/multiple-site-firewall.md This Terraform configuration defines a single firewall rule that is applied to multiple Unifi sites. It uses a `for_each` loop to iterate over a list of site IDs, setting the `site` attribute for each instance of the `unifi_firewall_rule` resource. This allows for consistent management and updates of firewall rules across various sites. ```terraform resource "unifi_firewall_rule" "rule" { # list of sites for_each = toset(["default", "vq98kwez", "bfa2l6i7"]) # use the key of the list as the site value site = each.key name = "drop all" action = "drop" ruleset = "LAN_IN" rule_index = 2011 protocol = "all" dst_address = var.ip_address } ``` -------------------------------- ### Manage Unifi Users from CSV with Terraform Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/guides/csv-users.md This Terraform configuration reads user data from a CSV file, decodes it, and creates or manages `unifi_user` resources. It maps MAC addresses, names, and notes from the CSV to the corresponding Terraform resource attributes. The configuration includes options for `allow_existing` and `skip_forget_on_destroy`. ```terraform locals { userscsv = csvdecode(file("${path.module}/users.csv")) users = { for user in local.userscsv : user.mac => user } } resource "unifi_user" "user" { for_each = local.users mac = each.key name = each.value.name # append an optional additional note note = trimspace("${each.value.note}\n\nmanaged by TF") allow_existing = true skip_forget_on_destroy = true } ``` -------------------------------- ### Retrieve Unifi Network Data by Name Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/network.md This Terraform snippet demonstrates how to retrieve Unifi network data using its name. It utilizes the 'unifi_network' data source and requires the 'name' attribute to specify the network. No external dependencies are needed beyond the Terraform Unifi provider. ```terraform #retrieve network data by unifi network name data "unifi_network" "lan_network" { name = "Default" } ``` -------------------------------- ### unifi_account Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/account.md Manages a RADIUS user account. ```APIDOC ## unifi_account (Resource) ### Description `unifi_account` manages a RADIUS user account. To authenticate devices based on MAC address, use the MAC address as the username and password under client creation. Convert lowercase letters to uppercase, and also remove colons or periods from the MAC address. ATTENTION: If the user profile does not include a VLAN, the client will fall back to the untagged VLAN. NOTE: MAC-based authentication accounts can only be used for wireless and wired clients. L2TP remote access does not apply. ### Schema #### Required - **name** (String) - The name of the account. - **password** (String, Sensitive) - The password of the account. #### Optional - **network_id** (String) - ID of the network for this account - **site** (String) - The name of the site to associate the account with. - **tunnel_medium_type** (Number) - See [RFC 2868](https://www.rfc-editor.org/rfc/rfc2868) section 3.2 Defaults to `6`. - **tunnel_type** (Number) - See [RFC 2868](https://www.rfc-editor.org/rfc/rfc2868) section 3.1 Defaults to `13`. #### Read-Only - **id** (String) - The ID of the account. ``` -------------------------------- ### Terraform User Group Import Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/user_group.md Demonstrates how to import an existing Unifi user group resource into Terraform management using its unique ID. This allows managing the resource through Terraform after initial creation outside of the provider. ```shell # import using the ID terraform import unifi_user_group.wifi 5fe6261995fe130013456a36 ``` -------------------------------- ### Terraform User Group Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/user_group.md Defines a Unifi user group resource in Terraform. It requires a name and can optionally configure maximum download and upload bandwidth rates (QOS) and associate with a specific site. Defaults are -1 for rates, meaning unlimited. ```terraform resource "unifi_user_group" "wifi" { name = "wifi" qos_rate_max_down = 2000 # 2mbps qos_rate_max_up = 10 # 10kbps } ``` -------------------------------- ### Retrieve Port Profile by Name - Terraform Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/port_profile.md This Terraform configuration block demonstrates how to use the `unifi_port_profile` data source to retrieve information about a port profile. It can optionally filter by name and site, and returns the port profile's ID. ```Terraform data "unifi_port_profile" "all" { } ``` -------------------------------- ### Retrieve Unifi User by MAC Address Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/user.md This Terraform code defines a data source to fetch details of a specific user (client) on the Unifi network. It requires the user's MAC address as input. The output includes various read-only properties of the user. ```terraform data "unifi_user" "client" { mac = "01:23:45:67:89:ab" } ``` -------------------------------- ### Terraform Configuration for unifi_wlan Resource Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/resources/wlan.md This Terraform configuration defines a WiFi network (SSID) using the unifi_wlan resource. It includes essential parameters like name, passphrase, and security type, along with advanced options for WPA3 support, PMF, and network associations. Dependencies on unifi_network, unifi_ap_group, and unifi_user_group resources are also shown. ```terraform variable "vlan_id" { default = 10 } data "unifi_ap_group" "default" { } data "unifi_user_group" "default" { } resource "unifi_network" "vlan" { name = "wifi-vlan" purpose = "corporate" subnet = "10.0.0.1/24" vlan_id = var.vlan_id dhcp_start = "10.0.0.6" dhcp_stop = "10.0.0.254" dhcp_enabled = true } resource "unifi_wlan" "wifi" { name = "myssid" passphrase = "12345678" security = "wpapsk" # enable WPA2/WPA3 support wpa3_support = true wpa3_transition = true pmf_mode = "optional" network_id = unifi_network.vlan.id ap_group_ids = [data.unifi_ap_group.default.id] user_group_id = data.unifi_user_group.default.id } ``` -------------------------------- ### unifi_dns_record Data Source Source: https://github.com/ubiquiti-community/terraform-provider-unifi/blob/main/docs/data-sources/dns_record.md The `unifi_dns_record` data source can be used to retrieve the ID for a DNS record by name. ```APIDOC ## unifi_dns_record Data Source ### Description The `unifi_dns_record` data source can be used to retrieve the ID for an DNS record by name. ### Method GET ### Endpoint /api/v2/sites/{site}/dns/records ### Parameters #### Query Parameters - **name** (String) - Optional - The name of the DNS record to look up, leave blank to look up the default DNS record. - **port** (Number) - Optional - The port of the DNS record. - **priority** (Number) - Optional - The priority of the DNS record. - **record_type** (String) - Optional - The type of the DNS record. - **site** (String) - Optional - The name of the site the DNS record is associated with. - **ttl** (Number) - Optional - The TTL of the DNS record. - **value** (String) - Optional - The value of the DNS record. - **weight** (Number) - Optional - The weight of the DNS record. ### Response #### Success Response (200) - **id** (String) - The ID of this DNS record. #### Response Example { "id": "603a7e1d5f8b1f00117e1b1f" } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.