How to forcibly remove the resource created by the broken module?
The workaround is to pull the current state file, edit it and use it as a base line. For example:

$ terraform state pull &gt; terraform.tfstate
$ vim terraform.tfstate # Carefully remove invalid entries.
$ python -mjson.tool terraform.tfstate # Validate JSON.


Note: In Vim, placing cursor on the opening bracket, hitting d% will remove the whole group.

Then plan and apply:

$ terraform plan -state=terraform.tfstate -refresh=false
$ terraform apply -state=terraform.tfstate -refresh=false




Alternatively, pull, edit and push your local state file into remote state:

$ terraform state pull &gt; terraform.tfstate
$ vim terraform.tfstate # Remove invalid entries and increase the serial value.
$ terraform state push terraform.tfstate




For Azure, it's better to use terraform-provider-azurerm instead of general DNS provider (terraform-provider-dns).