How does it handle failures? I.e in the first example it creates a server and then creates a dns record. What if the dns record creation fails? Does it roll back everything (i.e destroy the server)? I'd probably want a system that automatically retried x times before rolling back for some situations. In other situations I'd probably want it to not roll back or only roll back some of the tasks. How flexible is it?
Terraform saves partial state as it creates resources for these exact scenarios.
In your example, Terraform would create and save the ID of the server to state before going along to create the DNS record. If the DNS record failed to create for some external reason, the next `terraform apply` you ran would simply refresh the server and go on to create the DNS record.