Terraform erroring with 404 during plan instead of telling user that it will re-create the resource since it has gone missing
ckelner opened this issue · 6 comments
Terraform Version
0.9.5
Affected Resource(s)
- ibmcloud_infra_vlan
- ibmcloud_infra_lb_local
Debug Output
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
ibmcloud_infra_ssh_key.ssh_key: Refreshing state... (ID: 890467)
ibmcloud_infra_vlan.public_vlan: Refreshing state... (ID: 1805545)
ibmcloud_infra_vlan.private_vlan: Refreshing state... (ID: 1838589)
data.ibmcloud_cf_space.bx_space: Refreshing state...
data.ibmcloud_cf_org.bx_org: Refreshing state...
data.ibmcloud_cf_account.bx_account: Refreshing state...
ibmcloud_cf_service_instance.cloudant: Refreshing state... (ID: 80f08878-8c72-41cd-8f20-801c595f01c8)
ibmcloud_cf_service_key.cloudant_service_key: Refreshing state... (ID: 05e96796-31c1-4e62-ad30-6a0e99d573c7)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211105)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211067)
Error refreshing state: 4 error(s) occurred:
* ibmcloud_infra_vlan.public_vlan: ibmcloud_infra_vlan.public_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1805545'. (HTTP 404)
* ibmcloud_infra_vlan.private_vlan: ibmcloud_infra_vlan.private_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1838589'. (HTTP 404)
* module.click_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211105'. (HTTP 404)
* module.ad_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211067'. (HTTP 404)
Expected Behavior
I would assume, that because these resources were not found (404
s), that terraform should tell me that it wants to re-create them, not throw an error at me.
Actual Behavior
Terraform threw an error, reporting 404
from the cloud provider, preventing me from proceeding.
Steps to Reproduce
Create a VLAN or local load balancer with terraform apply
, then delete it out of band (meaning, not with terraform), then run terraform plan
- will result in 404
error(s) above.
@ckelner ,
Thanks for reporting 👍
The below shouldn't return err if code is 404.
https://github.com/IBM-Bluemix/terraform/blob/provider/ibm-cloud/builtin/providers/ibmcloud/resource_ibmcloud_infra_vlan.go#L272
@ashishth09 np 👍
I'm sure you are aware, but same issue will occur on any terraform action that calls refresh, as an example apply
and destroy
output as well:
terraform destroy
Do you really want to destroy?
Terraform will delete all your managed infrastructure.
There is no undo. Only 'yes' will be accepted to confirm.
Enter a value: yes
ibmcloud_infra_ssh_key.ssh_key: Refreshing state... (ID: 890467)
ibmcloud_infra_vlan.private_vlan: Refreshing state... (ID: 1838589)
ibmcloud_infra_vlan.public_vlan: Refreshing state... (ID: 1805545)
data.ibmcloud_cf_org.bx_org: Refreshing state...
data.ibmcloud_cf_space.bx_space: Refreshing state...
data.ibmcloud_cf_account.bx_account: Refreshing state...
ibmcloud_cf_service_instance.cloudant: Refreshing state... (ID: 80f08878-8c72-41cd-8f20-801c595f01c8)
ibmcloud_cf_service_key.cloudant_service_key: Refreshing state... (ID: 05e96796-31c1-4e62-ad30-6a0e99d573c7)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211067)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211105)
Error refreshing state: 4 error(s) occurred:
* module.ad_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211067'. (HTTP 404)
* ibmcloud_infra_vlan.public_vlan: ibmcloud_infra_vlan.public_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1805545'. (HTTP 404)
* module.click_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211105'. (HTTP 404)
* ibmcloud_infra_vlan.private_vlan: ibmcloud_infra_vlan.private_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1838589'. (HTTP 404)
ckelner:tf-bx-ad-serving ckelner$ terraform apply
ibmcloud_infra_vlan.private_vlan: Refreshing state... (ID: 1838589)
ibmcloud_infra_vlan.public_vlan: Refreshing state... (ID: 1805545)
ibmcloud_infra_ssh_key.ssh_key: Refreshing state... (ID: 890467)
data.ibmcloud_cf_org.bx_org: Refreshing state...
data.ibmcloud_cf_space.bx_space: Refreshing state...
data.ibmcloud_cf_account.bx_account: Refreshing state...
ibmcloud_cf_service_instance.cloudant: Refreshing state... (ID: 80f08878-8c72-41cd-8f20-801c595f01c8)
ibmcloud_cf_service_key.cloudant_service_key: Refreshing state... (ID: 05e96796-31c1-4e62-ad30-6a0e99d573c7)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211067)
ibmcloud_infra_lb_local.lb: Refreshing state... (ID: 211105)
Error refreshing state: 4 error(s) occurred:
* ibmcloud_infra_vlan.private_vlan: ibmcloud_infra_vlan.private_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1838589'. (HTTP 404)
* ibmcloud_infra_vlan.public_vlan: ibmcloud_infra_vlan.public_vlan: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '1805545'. (HTTP 404)
* module.ad_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211067'. (HTTP 404)
* module.click_server_loadbalancer.ibmcloud_infra_lb_local.lb: ibmcloud_infra_lb_local.lb: SoftLayer_Exception_ObjectNotFound: Unable to find object with id of '211105'. (HTTP 404)
The only way for a user to work around this is to modify their state manually by deleting the resources from the terraform.tfstate
json which can be highly error prone.
Absolutely, I'll scan for this behavior.
@renier I'll put together a small example, it will be best. This is a semi-large project with a lot of cruft. I'll post ASAP.
Here you go, fairly straightforward, LMK if you have questions. https://github.com/ckelner/tf-vlan-404-example