You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# create.tfresource"azurerm_resource_group""resource_group" {
name="resource_group_2"location="eastus2"
}
# This section is from a module, but for the purpose of reproducing it's simplified and added directly to the create.tf filedata"azurerm_resource_group""new_rg" {
name=azurerm_resource_group.resource_group.name
}
resource"azurerm_virtual_machine""vm" {
name="test_vm"location=data.azurerm_resource_group.new_rg.locationresource_group_name=data.azurerm_resource_group.new_rg.namevm_size="Standard_B1ls"delete_os_disk_on_termination=truedelete_data_disks_on_termination=truenetwork_interface_ids=[azurerm_network_interface.nic1.id]
storage_os_disk {
name="test_vm_osdisk"caching="ReadWrite"create_option="FromImage"
}
storage_image_reference {
publisher="Canonical"offer="UbuntuServer"sku="18.04-LTS"version="latest"
}
os_profile {
computer_name="testvm"admin_username="myadmin"admin_password="TestP@ss1!"
}
os_profile_linux_config {
disable_password_authentication=false
}
identity {
type="SystemAssigned"
}
}
resource"azurerm_network_interface""nic1" {
name="test_vm_nic"location=data.azurerm_resource_group.new_rg.locationresource_group_name=data.azurerm_resource_group.new_rg.nameip_configuration {
name="test_vm_ip"subnet_id=data.azurerm_subnet.subnet.idprivate_ip_address_allocation="Dynamic"
}
}
Expected Behavior
If this configuration is deployed and needs to be redeployed, sometimes it is easier to remove the configuration (instead of terraform taint), then add the configuration back to redeploy. It would be expected to redeploy successfully.
Actual Behavior
If a configuration is removed and applied, and then added back and applied, the data "azurerm_resource_group" "new_rg" resource will fail with Error: Error: Resource Group "resource_group_2" was not found
Steps to Reproduce
terraform init
terraform apply
mv create.tf create.tf.bak
terraform apply
mv create.tf.bak create.tf
terraform apply
Additional Context
If there is anything in the configuration after step 4, the error occurs. In this example, if the data "azurerm_subnet" data resource is also removed, the error does not occur.
I've found two ways to work around this bug
Remove everything else from the configuration and terraform apply, then add everything back. This obviously isn't ideal, but it does work in the example if I also remove the data "azurerm_subnet" data resource and terraform apply, then add everything back, terraform apply will work again. If I remove the subnet data, terraform apply, add the subnet data back and terraform apply again, then add all the resources back, the error re-occurs.
Add only the new_rg resource back, terraform apply, then add the rest of the resources that go in that resource group.
The text was updated successfully, but these errors were encountered:
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
ghost
locked and limited conversation to collaborators
Jan 20, 2020
This issue was closed.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Terraform Version
Terraform Configuration Files
Expected Behavior
If this configuration is deployed and needs to be redeployed, sometimes it is easier to remove the configuration (instead of
terraform taint
), then add the configuration back to redeploy. It would be expected to redeploy successfully.Actual Behavior
If a configuration is removed and applied, and then added back and applied, the
data "azurerm_resource_group" "new_rg"
resource will fail withError: Error: Resource Group "resource_group_2" was not found
Steps to Reproduce
terraform init
terraform apply
mv create.tf create.tf.bak
terraform apply
mv create.tf.bak create.tf
terraform apply
Additional Context
If there is anything in the configuration after step 4, the error occurs. In this example, if the
data "azurerm_subnet"
data resource is also removed, the error does not occur.I've found two ways to work around this bug
terraform apply
, then add everything back. This obviously isn't ideal, but it does work in the example if I also remove thedata "azurerm_subnet"
data resource andterraform apply
, then add everything back,terraform apply
will work again. If I remove the subnet data,terraform apply
, add the subnet data back andterraform apply
again, then add all the resources back, the error re-occurs.terraform apply
, then add the rest of the resources that go in that resource group.The text was updated successfully, but these errors were encountered: