-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Order to change/destroy with dependent resources #20196
Comments
I am hitting this same problem right now. I create a network and then a firewall for the network, but it fails the delete because it tries to destroy the network first, upon which the firewall relies:
I have to imagine there is a means to get it to destroy in the correct order without swapping the blocks in the config file. Help appreciated. :) |
Maybe try setting the resource's lifecycle to create before destroy?
Useful reference |
Thank you @gpanula :-) but in my case there's no need to destroy-and-recreate a resource, but to update a resource and only then, destroy the resource on which the first resource depends on. |
@maxgio92 have you confirmed the dependency graph in this case (using |
@paultyng yes |
@maxgio92 do you have a workaround for this problem? |
I'm hitting the same issue with openstack provider, during |
I had the same issue today targeting Openstack with Terraform v0.12.2 and provider.openstack v1.19.0. TF tried to destroy sub network first while the VM using it and a related port still was there. I had to remove this VM manually and then everything went well. |
After I added "depends_on" clause to my compute definition it worked very well so the destroy process worked in proper order: resource "openstack_compute_instance_v2" "my-vm" { |
@mangobatao I'm sorry but not yet :-( |
We are currently experiencing problems we believe are similar to this. We are relying on Terraform using implicit dependencies to figure out the order for creating resources. So far, 100% of the time it does the right thing. However, when it comes time for destroying the resources, it seems like 50% of the time it deletes them in the wrong order, meaning the resource that has a dependency is deleted first and then it attempts to delete the dependent resource next, which fails. |
I encoutered same problem while destroy aws_api_gateway_deployment, I recieved error:
The error happend because aws_api_gateway_base_path_mapping is still exist although I have added to it an property: depends_on API Gateway Deployment It seem destroy action is not in correct order base on depends_on property |
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. |
Hi all,
I'm trying to write a module for AWS Elasticache service and actually I have two resources:
that depends on:
The dependence is not implicit, since I would want to make it optional in order to create a custom parameter group and configure the replication group to use it and otherwise configure in such a way that it will use the default one.
During creation all works fine, but if I have the two resources created and I want to restore the default parameter group (thus also remove the custom one), the change and destroy order does not work in the order in which I would have expected, despite the explicit dependence.
If I am wrong, sorry, I'm a TF newbie :-)
Terraform Version
Terraform Configuration Files
modules/aws_elasticache/variables.tf
modules/aws_elasticache/main.tf
main.tf
Expected Behavior
First it should be changed the replication group's resource and then destroyed the parameter group resource.
Actual Behavior
It attempts first to destroy the parameter group resource, but since the replication group resource depends on it, it fails.
Steps to Reproduce
terraform plan
terraform apply
It creates the two resources, the replication group dependent on the parameter group.
main.tf
terraform plan
It appears that the replication group's "parameter_group_name" field would be change and that the parameter group resource would be destroyed.
terraform apply
It attempts to destroy first the parameter group, before updating the field "parameter_group_name" of the replication group.
Thank you very much!
The text was updated successfully, but these errors were encountered: