This repository is an example of how you can set up your home network running on Ubiquiti's Unifi Dream Machine (UDM) (probably on other Ubiquiti's products as well, but, I only have the UDM and thus cannot vouch for the others) using Terraform and its community provider for Unifi.
Kudos to Paul Tyng for the creation of the Unifi provider for Terraform!
- this example uses Terraform v0.13
- I use the
terraform.tfvars
file for passing the secrets in. If you plan on doing the same, you ought to git ignore it - the credentials I use for running Terraform on my UDM come from a super admin user who had been created outside of Terraform (manually, through the UDM's GUI)
- the default LAN network, the one that's created automatically upon the first boot of the UDM, is excluded on purpose from this setup
- if, as myself, you're too lazy to plug your machine to the UDM with an ethernet cable, expect errors (e.g.
Error: unable to determine API URL style: ...
) caused by the intermittent disruptions of the WiFi connection that occur when UDM applies your changes - there are two important aspects of Terraform that you should consider before adopting this example:
Use the Core Terraform Workflow:
a) git clone this repo
git clone git@github.com:rafalkrol-xyz/ubiquity-unifi-dream-machine-setup-example.git
b) make the necessary changes to Terraform variables (e.g. set the proper password
and username
)
c) initialize Terraform
terraform init
d) review plan
terraform plan
e) if happy with everything, apply the changes
terraform apply
If you started with the default UDM settings, this is what you should end up with:
- networks
- Wi-Fi networks
- firewall groups
- firewall rules