Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use both API key and org ID #840

Closed
monodot opened this issue Mar 7, 2023 · 0 comments · Fixed by #844
Closed

Cannot use both API key and org ID #840

monodot opened this issue Mar 7, 2023 · 0 comments · Fixed by #844
Labels

Comments

@monodot
Copy link

monodot commented Mar 7, 2023

Hi, I'm seeing this issue after upgrading to 1.35.0.

I use the provider to add Library Panels to a Grafana Cloud instance. The library panel provisioning actually completes successfully (I can see the Library Panel inside Grafana!) but Terraform seems to throw this error immediately afterwards (example below).

This is strange because I'm not specifying an org ID anywhere, at least not that I'm aware of.

The error even prevents me from running any further Terraform actions (including terraform destroy), so I have to manually remove items from the Terraform state.

Terraform Version

  • Terraform: 1.3.7
  • Terraform Grafana Provider: 1.35.0
  • Grafana: Cloud (Grafana 9.3.6)

Affected Resource(s)

  • grafana_library_panel

Terraform Configuration Files

To be provided :)

Debug Output

To be provided :)

Expected Behavior

The provider should create library panels and other resources.

Actual Behavior

When I run terraform apply for the first time, the provider creates the library panels successfully (I can see them inside Grafana), but then subsequent operations seem to fail with this error:

│ Error: cannot use both API key and org ID. API keys are scoped to single org
│ 
│   with module.artifacts_tst02user02.grafana_library_panel.latency_profile_sockshop,
│   on ../../../field-eng-infra/terraform/modules/workshops/dashboard-makeover-artifacts/librarypanels.tf line 11, in resource "grafana_library_panel" "latency_profile_sockshop":
│   11: resource "grafana_library_panel" "latency_profile_sockshop" {
│ 

The error then occurs again when I run terraform apply again, and even terraform destroy, preventing objects from being created or destroyed.

This seems to be happening since we upgraded to 1.35.0 of the provider - I tested it a few times with 1.34.0 and didn't see this error at all.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create Grafana Cloud stack
  2. Create an API key for the instance (using grafana_api_key)
  3. Use that key to configure a second Provider, with auth set to the API key, and url set to the URL of the Grafana instance
  4. Use grafana_library_panel to add the LIbrary Panel to the instance.
  5. terraform apply

Here's how we're defining a library panel resource - this is located inside a module:

resource "grafana_library_panel" "blank_space" {
  name = "Blank Space"
  model_json = file("${path.module}/librarypanels/blank-space.json")
}

And here's an example of configuring the provider that is then passed to our module:

  "provider": {
    "grafana": [
      {
        "alias": "myprovider",
        "auth": "${module.workshop_infra.stack_obj[\"tom@example.com\"].hosted_grafana_key}",
        "retries": 25,
        "url": "${module.workshop_infra.stack_obj[\"tom@example.com\"].config.url}"
      }
    ]
  }

Important Factoids

We're using Grafana Cloud.

@monodot monodot added the bug label Mar 7, 2023
julienduchesne added a commit that referenced this issue Mar 9, 2023
* Fix `library_panel` failing to be managed with API key
Fixes #840
To be combined with grafana/grafana-api-golang-client#136

* Update client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant