Fixing cycle errors
In Chapter 2, Writing Terraform Configurations, in the Managing Terraform resource dependencies recipe, we learned how to use implicit and explicit Terraform dependencies.
In some cases, when we use lots of dependencies between resources, we can get a cycle error between Terraform resources (such as cases where the resource depends on itself within the chain of dependencies).
To understand the concept of Terraform dependencies and cycle errors, read this explanation: https://serverfault.com/a/1005791
Let’s get started!
Getting ready
For this recipe, we will start with the following configuration in main.tf
(it’s only a part of the configuration):
resource "azurerm_linux_virtual_machine" "vm" {
name = "myvmdemo-${random_string.str.result}"
network_interface_ids = [azurerm_network_interface.nic.id]
resource_group_name = azurerm_resource_group...