USGs commonly want to be provisioned via their LAN interfaces which can be a pain when you have a cloud / external controller. The example below shows connecting a USG to an external UniFi controller via the WAN port of the USG (natively DHCP client).

Connect to serial console (115200) or SSH to the LAN interface (default credentials ubnt/ubnt)
Run the below commands substituting the DNS name 'unifi' & the IP address for something appropriate that points to your UniFi controller.

set system static-host-mapping host-name unifi alias setup
set system static-host-mapping host-name unifi inet

Adopt in the controller UI & wait. You can also the command 'unifi info' for status at the CLI of the USG, be patient though as it takes a few minutes to adopt.