terraform-provider-grafana icon indicating copy to clipboard operation
terraform-provider-grafana copied to clipboard

New version of Grafana/Grafana TF provider causes TF to not recognize items in previous state

Open ryanisnan opened this issue 3 years ago • 7 comments

Terraform Version

  • Terraform: 0.14.9
  • Terraform Grafana Provider: 1.12.0
  • Grafana: 8

Affected Resource(s)

Please list the resources as a list, for example:

  • grafana_dashboard

This issue is affecting multiple resources.

Terraform Configuration Files

Too large, but shouldn't be too relevant. Resources have been fine for some months unchanged.

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Context

  • No changes were done to our HCL code
  • Our provider version has the constraint ~> 1.5.0 (which will install 1.12 at present)
  • The state is managed by Terraform Cloud
  • A plan was executed that contained entirely unrelated changes (adding an RDS parameter group)

Expected Behavior

Terraform should have detected either a no-op change with the resources already in the state, or perhaps some changes to adapt the resources to work with the new Grafana 8.0 provider updates.

Actual Behavior

Terraform indicated that it wanted to create all grafana resources that were currently in the state.

Steps to Reproduce

  • Have resources provisioned on Grafana 7 and in the Terraform state
  • Upgrade to Grafana 8
  • Upgrade to the newest Grafana AWS Provider
  • Run a terraform plan
  • Watch terraform seemingly forget about your resources

Important Factoids

  • Our grafana instance is a hosted grafana instance
  • We were automatically upgraded to v8, but the resources existed prior to the upgrade

References

Nothing else I saw.

ryanisnan avatar Jun 25 '21 18:06 ryanisnan

Hi @ryanisnan. Which version of the Grafana provider did you upgrade from?

trotttrotttrott avatar Jun 25 '21 19:06 trotttrotttrott

The reason I ask is because we expect the dashboard_id field to be present in order to migrate the schema in 0.12.0 from using slug to UID. The dashboard_id field did not come along until 0.7.0. If you upgraded from a version earlier than 0.7.0, this might explain the problem.

trotttrotttrott avatar Jun 25 '21 20:06 trotttrotttrott

Same for us not even for dashboards but for users as well

biokys avatar Jun 29 '21 10:06 biokys

Ooh, interesting. You are probably right (though I assume you are meaning (1.7.0?) - We were using 1.5.0 most likely (that was our pinned major version at the time the code was written, so most dashboards would have been created about the same time, with minor updates here and there).

ryanisnan avatar Jun 29 '21 23:06 ryanisnan

The above mentioned migration seems likely to be the culprit. I am curious though if in the future something like this change might be reserved for a major version upgrade (e.g. 2.x) - I'm wary of using the ~> operator if this sort of deprecation pattern is to be expected. Thanks for digging into this @trotttrotttrott! Really appreciate this project.

ryanisnan avatar Jun 29 '21 23:06 ryanisnan

Well, maybe I should leave my scenario too, since I'm facing the same error. I'm using terraform-provider-grafana v1.10.0 and upgraded grafana from 7.5.9 to v8.0.3. Since this update terraform-provider-grafana modules "lost" its state and it's trying to recreate the resources. Let me know if I could contribute with more information.

oliveirafilipe avatar Jun 30 '21 19:06 oliveirafilipe

Well, maybe i'll delete the dashboard and recreate them. I deleted one of my dashboards via Grafana's UI, since I was getting the following error: Error: status: 412, body: {"message":"A dashboard with the same name in the folder already exists","status":"name-exists"}

Updated to use terraform-provider-grafana v1.12.0 and it recreate the dashboard as expected :shrug:

oliveirafilipe avatar Jun 30 '21 20:06 oliveirafilipe