gruntwork-io / terragrunt

Terragrunt is a flexible orchestration tool that allows Infrastructure as Code written in OpenTofu/Terraform to scale.
https://terragrunt.gruntwork.io/
MIT License
8.09k stars 981 forks source link

Azure Private DNS destroys the VM #1471

Open khandujaniket opened 3 years ago

khandujaniket commented 3 years ago

I have two azure TF modules

Linux Virtual Machine Private DNS I am using Terragrunt as a wrapper on TF. Private DNS is dependent on Virtual Machine and this dependency is maintained in Terragrunt.

Terraform Version 0.14.3

When I execute the Terragrunt apply-all following happens

VM is created and output is presented Then Private DNS starts provisioning and then it starts destroying the VM. I am unable to pin point the issue. I have a single state file for both modules.

terraform apply -no-color -input=false -auto-approve Acquiring state lock. This may take a few moments... tls_private_key.ssh: Refreshing state... [id=178eebbd453724bd63cdee4deba03b82cd31c284] local_file.private_key[0]: Refreshing state... [id=3eb0bb67ac9ff933ca5a58027cbf4f32e2689a64] data.azurerm_virtual_network.virtual_network: Refreshing state... azurerm_resource_group.jump_resource_group[0]: Refreshing state... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360] azurerm_network_interface.network_interface: Refreshing state... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360/providers/Microsoft.Network/networkInterfaces/nic-dev288-jumphost-mso360] azurerm_linux_virtual_machine.jump_machine: Refreshing state... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360/providers/Microsoft.Compute/virtualMachines/vm-dev288-jumphost-mso360] azurerm_resource_group.private_dns_resource_group[0]: Creating... azurerm_linux_virtual_machine.jump_machine: Destroying... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360/providers/Microsoft.Compute/virtualMachines/vm-dev288-jumphost-mso360] azurerm_resource_group.private_dns_resource_group[0]: Creation complete after 4s [id=/subscriptions//resourceGroups/rg_pdns_RG-dev288-01_mso360] azurerm_private_dns_zone.private_dns: Creating... azurerm_linux_virtual_machine.jump_machine: Still destroying... [id=/subscriptions/-...alMachines/vm-dev288-jumphost-mso360, 10s elapsed] azurerm_private_dns_zone.private_dns: Still creating... [10s elapsed] azurerm_linux_virtual_machine.jump_machine: Still destroying... [id=/subscriptions/-...alMachines/vm-dev288-jumphost-mso360, 20s elapsed] azurerm_private_dns_zone.private_dns: Still creating... [20s elapsed] azurerm_linux_virtual_machine.jump_machine: Still destroying... [id=/subscriptions/-...alMachines/vm-dev288-jumphost-mso360, 30s elapsed] azurerm_private_dns_zone.private_dns: Still creating... [30s elapsed] azurerm_linux_virtual_machine.jump_machine: Still destroying... [id=/subscriptions/-...alMachines/vm-dev288-jumphost-mso360, 40s elapsed] azurerm_private_dns_zone.private_dns: Creation complete after 38s [id=/subscriptions//resourceGroups/rg_pdns_rg-dev288-01_mso360/providers/Microsoft.Network/privateDnsZones/skyblue.corp.amdocs.azr] azurerm_private_dns_a_record.records["dev288-jumphost"]: Creating... azurerm_private_dns_zone_virtual_network_link.private_dns_link: Creating... azurerm_private_dns_a_record.records["dev288-jumphost"]: Creation complete after 5s [id=/subscriptions//resourceGroups/rg_pdns_rg-dev288-01_mso360/providers/Microsoft.Network/privateDnsZones/skyblue.corp.amdocs.azr/A/dev288-jumphost] azurerm_linux_virtual_machine.jump_machine: Still destroying... [id=/subscriptions/-...alMachines/vm-dev288-jumphost-mso360, 50s elapsed] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [10s elapsed] azurerm_linux_virtual_machine.jump_machine: Destruction complete after 1m0s tls_private_key.ssh: Destroying... [id=178eebbd453724bd63cdee4deba03b82cd31c284] azurerm_network_interface.network_interface: Destroying... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360/providers/Microsoft.Network/networkInterfaces/nic-dev288-jumphost-mso360] tls_private_key.ssh: Destruction complete after 0s azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [20s elapsed] azurerm_network_interface.network_interface: Still destroying... [id=/subscriptions/-...nterfaces/nic-dev288-jumphost-mso360, 10s elapsed] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [30s elapsed] azurerm_network_interface.network_interface: Destruction complete after 13s azurerm_resource_group.jump_resource_group[0]: Destroying... [id=/subscriptions//resourceGroups/rg_RG-dev288-01_mso360] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [40s elapsed] azurerm_resource_group.jump_resource_group[0]: Still destroying... [id=/subscriptions/-...urceGroups/rg_RG-dev288-01_mso360, 10s elapsed] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [50s elapsed] azurerm_resource_group.jump_resource_group[0]: Still destroying... [id=/subscriptions/-...urceGroups/rg_RG-dev288-01_mso360, 20s elapsed] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Still creating... [1m0s elapsed] azurerm_resource_group.jump_resource_group[0]: Still destroying... [id=/subscriptions/-...urceGroups/rg_RG-dev288-01_mso360, 30s elapsed] azurerm_private_dns_zone_virtual_network_link.private_dns_link: Creation complete after 1m10s [id=/subscriptions//resourceGroups/rg_pdns_rg-dev288-01_mso360/providers/Microsoft.Network/privateDnsZones/skyblue.corp.amdocs.azr/virtualNetworkLinks/vnet-dns-link] azurerm_resource_group.jump_resource_group[0]: Still destroying... [id=/subscriptions/-...urceGroups/rg_RG-dev288-01_mso360, 40s elapsed] azurerm_resource_group.jump_resource_group[0]: Destruction complete after 49s

yorinasub17 commented 3 years ago

It's a bit hard to tell what is going on here without seeing the code, but my best guess as to what is happening is that you have somehow gotten the state files mixed up so that both modules are using the same state representation.

How are you configuring the state? Are you able to share your terragrunt.hcl configuration?