ibm-cloud-docs / ibm-cloud-provider-for-terraform

Documentation repository for ibm-cloud-provider-for-terraform
3 stars 17 forks source link

How to avoid conflicting error of deleting a resource if it has different types of attachments. #22

Open kyunghoryu opened 2 years ago

kyunghoryu commented 2 years ago

I have noticed that "depend_on" needs to be added to avoid conflicting update error if a resource has different types of attachments.

For example, terraform code I used resource "ibm_is_instance_volume_attachment" "iac_attach_app_volume" {

#depends_on = [ ibm_is_floating_ip.iac_test_floating_ip ]

count = var.home_fs_size > 0 ? 1 : 0 instance = ibm_is_instance.iac_test_instance.id name = "${var.project_name}-${var.environment}-volume-01-att" volume = ibm_is_volume.iac_app_volume[0].id

If the "depends_on" is not applied, the following error occurs when I tried to destroy it.

ibm_is_instance_volume_attachment.iac_attach_app_volume[0]: Destroying... [id=0717_1a3fbc00-807b-4d01-9590-814ccfb61a05/0717-abdd070e-f2bd-4a7f-8690-8a1702b9563c] ibm_is_security_group_rule.iac_test_security_group_rule_tcp_ssh: Destroying... [id=r006-a7d3d85e-066b-45b5-931f-440d2bee64fb.r006-e444f91b-2a3f-4a94-bda8-38a8a783539f] ibm_is_security_group_rule.iac_test_security_group_rule_all_outbound: Destruction complete after 2s ibm_is_security_group_rule.iac_test_security_group_rule_tcp_ssh: Destruction complete after 3s ibm_is_floating_ip.iac_test_floating_ip: Still destroying... [id=r006-a2fc0299-b709-4aad-baf2-36cdd051e015, 10s elapsed] ibm_is_floating_ip.iac_test_floating_ip: Destruction complete after 12s ╷ │ Error: Error while deleting volume attachment (0717-abdd070e-f2bd-4a7f-8690-8a1702b9563c) from instance (0717_1a3fbc00-807b-4d01-9590-814ccfb61a05) : "Conflicting update of instance, please retry request" │

I also discussed it to get an advise at "terraform-ibmcloud-users" slack channel.