splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
103 stars 76 forks source link

terraform fails if a managed resource is deleted in the splunk gui #86

Open dmoe86 opened 3 years ago

dmoe86 commented 3 years ago

if you create a role with this provider and then someone removes the role in the splunk web gui, the next run of terraform plan will fail with the error "unable to find resource" instead of recreating the resource.

jsworkaccount commented 3 years ago

I have noticed the same. The provider historically hasn't liked drift one bit (be it deletion or just out-of-band configuration changes).

I often work around this by logging into the system running terraform (not always a trivial task), performing a state rm (again, not always trivial, when resource addresses are potentially being dynamically populated), and re-run my code. It is probably possible to automate this, but it seems like Terraform is generally intended to be able to reconcile state on refresh, in spirit at least. I know that this is not a viable option in many situations; it's certainly neither elegant nor preferred.

JosephHobbs commented 2 years ago

Yea, in my experience this is a provider maturity thing. Some providers will handle the 404 understanding that it means the object no longer exists and assume it needs to be created. Other providers simply treat the 404 as an error and pass it up the stack.

I'll be honest in that most Terraform admins I know know enough to use it, but messing with state is beyond their capability. If the provider can recognize that a 404 means the object was deleted and recreate it, that's the route I'd go...

wkleinhenz commented 2 years ago

Im seeing this same issue but with apps that havent been installed yet, terraform will correctly handle apps that ive already installed or at least wont error with them but when it reaches ones that havent been installed itll throw a Unable to find resource: