VM deployment delay until custom_data script is complete


Using the Azure provider, is there anyway when deploying multiple VM’s to wait until each one has fully completed its custom_data scripts before moving onto the next? I have read that using things like time_sleep isn’t recommended. Is there any built in way to cease the deployment until the scripts are all completed? It looks like the VM is considered complete once its created in the portal however when trying to require installation of modules on the VM before the next that references it is created is causing a sort of race condition issue.

I’m new to Terraform so any pointers would be much appreciated.