Waiting for a reboot with Terraform


I am provisioning hetzner cloud servers which are running a unattended install on first boot, then reboots. I need to run a local-exec provisioner after this installation procedure is finished.

If I add the provisioner to the server resource, it seems to run as soon as the server is booted, long before the installation has finished.

My second approach was to use a null_resource with a trigger on the servers status, but terraform seems to finish its process as soon as all resources a provisioned, before the trigger has a change to act on the ‘reboot’ status.

How can I make terraform wait for this reboot?