Forum Discussion
Crossplane Metal provider - lifecycle.prevent_destroy error
After I spin up a Metal Device using the Crossplane Equinix provider, it comes up but in the events I see the following. I'm not sure if it is expected or a bug?
Managed resource event message:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal CreatedExternalResource 3m7s managed/metal.equinix.jet.crossplane.io/v1alpha1, kind=device Successfully requested creation of external resource
Warning CannotObserveExternalResource 13s (x6 over 30s) managed/metal.equinix.jet.crossplane.io/v1alpha1, kind=device cannot run plan: plan failed: Instance cannot be destroyed: Resource equinix_metal_device.my-gateway-sv-4x2x4-4gfpq has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed. To avoid this error and continue with the plan, either disable lifecycle.prevent_destroy or reduce the scope of the plan using the -target flag.
Field in XRD for plan is: "plan: m3.small.x86"
Environment:
Crossplane v1.16
Equinix Provider: v0.6.1
K8s: Kind 1.27
- MarquesEquinix Employee
Are you using a management policy or non-default delete policy? https://docs.crossplane.io/latest/concepts/managed-resources/#interaction-with-management-policies
I see "has lifecycle.prevent_destroy set, but the plan calls for this resource to be destroyed" in a number of provider GitHub issues, for AWS, Azure, and others.
I'm curious if the deletion is being triggered due to some detected drift and a need to update based on the plan. I would expect the resource to successfully delete and recreate in that case (perhaps in a loop, which wouldn't be desirable).
It would help to have a better example of the minimum XRD to reproduce this problem. Debugging output from the provider may also reveal some helpful details: https://docs.crossplane.io/latest/guides/troubleshoot-crossplane/#provider-logs