-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redeploying a resource group and child resources fails with "Error: Resource group was not found" when using a data resource within a module #5233
Comments
I did some more testing and you actually don't need to create any resources. Simply creating the resource group and having a data resource with the output from the resource group creation is enough to cause this issue to happen. # create.tf
resource "azurerm_resource_group" "resource_group" {
name = "resource_group_2"
location = "eastus2"
}
data "azurerm_resource_group" "new_rg" {
name = azurerm_resource_group.resource_group.name
}
|
Has there been any progress on this issue? I am seeing the exact same behavior when attempting to use the resource group data source, in Azurerm provider 1.39 (tf version .012) data "azurerm_resource_group" "core-rg" { I get "Error: Error: Resource Group "rg_name" was not found" And if i try to use the rg data source, as a reference for another data source, i get both data sources dont exist data "azurerm_key_vault" "kv" { I get "Error: KeyVault "kv_name" (Resource Group "rg_name") does not exist" This is prohibiting me from using my modules now that i have upgraded to .012 to take advantage of new features |
#Bump |
Same issue when re-running a plan/apply when a VM has been "deleted" via the console. cannot rerun which should re-add the VM. |
Hi, Same issue when re-running a plan/apply when a VM has been "deleted" via the console. cannot rerun which should re-add the VM. Is there a workaround for this issue? ETA for fix? Please advise. |
The same issue appears when using a subnet. |
This still occurs. I have a similar config where i deploy a number of VMs. The initial apply works, but if I increase the number of VM's after the fact, it fails stating the resource group was not found. |
+1 I'm hitting a similar issue for ANYTHING that needs a Resource Group and I happen to deploy a RG alongside any resources that will be inside said RG. One day... one day we will finally finally get depends_on support for modules (which I am using in my case). |
👋 Taking a look through here this appears to be an issue regarding Module Dependencies - which unfortunately aren't supported in Terraform Core at this time. As such I'm going to close this in favour of the upstream issue on Terraform Core where this is being tracked: hashicorp/terraform#10462 - would you mind subscribing to that issue for updates? Thanks! |
@tombuildsstuff I'm not sure why you think this is about Module dependencies, please see the first example. modules aren't being used. In my use case just deleting a VM on the console has the same problem. |
@tombuildsstuff The original example is from a module, but it isn't trying to use the explicit This works the first time it's used, but a redeploy is what causes the inconsistent plan. |
@tombuildsstuff or @katbyte , Can this issue please be re-opened as it is not an issue regarding Module dependencies? We would greatly appreciate it as this issue resurfaces in our environment at least once a week in our pipelines. |
Running into this problem it's very confusing why this is an issue. Unfortunately, they closed the ticket as "too heated"!!! I'm capturing a simple use case here for... posterity, I suppose.
This makes no sense since we're explicitly declaring the resource as a dependent variable to the module, even though we don't have the strict |
I am seeing the same issue with Terraform v0.12.24 |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
This issue was originally opened by @derekwinters as hashicorp/terraform#23738. It was migrated here as a result of the provider split. The original body of the issue is below.
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: