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

Error trying to import dashboard - unsupported protocol scheme "" #257

Closed
udh-mendix opened this issue Aug 6, 2021 · 9 comments · Fixed by #395
Closed

Error trying to import dashboard - unsupported protocol scheme "" #257

udh-mendix opened this issue Aug 6, 2021 · 9 comments · Fixed by #395

Comments

@udh-mendix
Copy link

Terraform Version

Terraform: 0.12.9
Terraform Grafana Provider: 1.13.3
Grafana: v8.0.6

Affected Resource(s)

grafana_dashboard

Terraform config

provider "grafana" {
  url  = var.grafana_url
  auth = var.grafana_auth
  version = "~> 1.5.0"
}

resource "grafana_data_source" "xyz" {
  type = "influxdb"
  name = "xyz"

  url            = var.influxdb_url
  database_name = var.influxdb_name
  username      = var.influxdb_username
  password      = var.influxdb_password

  access_mode = "direct"
}

resource "grafana_dashboard" "abc" {
  config_json = var.abc_dashboard_json
  folder      = var.abc_dashboard_folder_id
  depends_on  = [grafana_data_source.xyz]
}

Expected Behavior

Importing grafana dashboard should succeed

Actual Behaviour

Import fails with following error -

Error: Get /api/dashboards/db/abc: unsupported protocol scheme ""

grafana_url is a HTTPS URL, so its unclear why I'm getting this error.

Steps to Reproduce

Import grafana dashboard into terraform
terraform import grafana_dashboard.abc abc-slug

@justinTM
Copy link
Contributor

justinTM commented Aug 25, 2021

same/similar issue here:

Error: Post "/api/folders": unsupported protocol scheme ""
431  on folders.tf line 9, in resource "grafana_folder" "metrics":
432   9: resource "grafana_folder" "metrics" {

Terraform: 0.13
Terraform Grafana Provider: 1.13.4
Grafana: v8.1.2

@justinTM
Copy link
Contributor

This error is encountered for one environment but not the other. Both environments have the same versions for Terraform, Grafana (both hosted instances of Grafana Cloud, with different domains), and Grafana provider plugin.

The failing instance is a Grafana Cloud trial instance (quotas/limits to number of resources).
The successful instance is a Grafana Cloud company-wide domain (i.e., <company-name>.grafana.net).

@justinTM
Copy link
Contributor

The error has miraculously disappeared when upgrading to Terraform 1.0 (same other versions). Not sure if coincidence or cause.

@inkel
Copy link
Contributor

inkel commented Aug 30, 2021

Hi, @justinTM and @udh-mendix, I just wanted to confirm something in order to reprodue: suppose your dashboard URL is http://example.net/d/abc123/some-name, what value are you using for importing the dashboard:

terraform import grafana_dashboard.sample abc123
# or
terraform import grafana_dashboard.samepl some-name

I know the documentation says to use the slug, but I'm afraid that might be wrong.

Thanks!

@udh-mendix
Copy link
Author

Hi @inkel, I've tried with both and it fails with the same error.

@inkel
Copy link
Contributor

inkel commented Aug 30, 2021

Thanks. Can you paste me the full error output?

@udh-mendix
Copy link
Author

udh-mendix commented Aug 31, 2021

I've tried with both dashboard ID and the slug, and its the same error.

Command for dashboard http://example.net/d/l9ji-5wWz/abc-slug -

terraform import -var-file=abcvarfile.tfvars module.grafana.grafana_dashboard.abc l9ji-5wWz

Relevant TF debug logs -

module.grafana.grafana_dashboard.abc: Importing from ID "l9ji-5wWz"...
module.grafana.grafana_dashboard.abc: Import prepared!
Prepared grafana_dashboard for import
module.grafana.grafana_dashboard.abc: Refreshing state... [id=l9ji-5wWz]
2021/08/31 11:11:06 [ERROR] module.grafana: eval: *terraform.EvalRefresh, err: Get /api/dashboards/db/l9ji-5wWz: unsupported protocol scheme ""
2021/08/31 11:11:06 [ERROR] module.grafana: eval: *terraform.EvalSequence, err: Get /api/dashboards/db/l9ji-5wWz: unsupported protocol scheme ""
2021/08/31 11:11:06 [TRACE] [walkImport] Exiting eval tree: import module.grafana.grafana_dashboard.abc result
2021/08/31 11:11:06 [TRACE] vertex "import module.grafana.grafana_dashboard.abc result": visit complete

julienduchesne added a commit that referenced this issue Feb 21, 2022
This leads to confusing bug reports. An example is the one below. It's about importing a resource but it's in fact an invalid URL
Fixes #257
julienduchesne added a commit that referenced this issue Feb 21, 2022
This leads to confusing bug reports. An example is the one below. It's about importing a resource but it's in fact an invalid URL
Fixes #257
@udh-mendix
Copy link
Author

@julienduchesne thanks for getting this fixed in #395. When will the release be cut? I'm waiting for that so terraform can pick up the latest tag.

@julienduchesne
Copy link
Member

@julienduchesne thanks for getting this fixed in #395. When will the release be cut? I'm waiting for that so terraform can pick up the latest tag.

This was released in v1.20.0

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

Successfully merging a pull request may close this issue.

4 participants