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

Provider cannot connect to Grafana instance, throws 401 Unauthorized #77

Closed
neocorp opened this issue Nov 28, 2019 · 9 comments
Closed
Assignees

Comments

@neocorp
Copy link

neocorp commented Nov 28, 2019

Hi there,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved for bug reports and feature requests. For general usage questions, please see: https://www.terraform.io/community.html.

Terraform Version

Terraform v0.12.16

  • provider.aws v2.39.0
  • provider.grafana v1.4.0
  • provider.null v2.1.2
  • provider.random v2.2.1

Affected Resource(s)

  • grafana_data_source

Issue seems to be with Grafana provider itself, it cannot seem to authenticate.

Terraform Configuration Files

provider "grafana" {
  url = "https://grafana.${var.platform_domain_name}"
  auth = "${var.grafana_admin_username};${var.grafana_admin_password}"
  version = "1.4"
}

resource "grafana_data_source" "staging" {
  name                = "Staging"
  type                = "cloudwatch"

  json_data {
    auth_type       = "arn"
    default_region  = var.region
    assume_role_arn = "arn:aws:iam::${lookup(var.aws_account_ids, "staging")}:role/grafana"
  }
}

resource "grafana_data_source" "qa" {
  name                = "QA"
  type                = "cloudwatch"

  json_data {
    auth_type       = "arn"
    default_region  = var.region
    assume_role_arn = "arn:aws:iam::${lookup(var.aws_account_ids, "qa")}:role/grafana"
  }
}

Debug Output

https://gist.github.com/neocorp/72468d6c33c34dafabc6c97f6cc662cf

Panic Output

N/A

Expected Behavior

Grafana provider should be able to connect to Grafana and create the data sources.

Actual Behavior

Terraform throws 401 Unauthorized error. Using username/password combination or API Token from Grafana doesn't make a difference, produces the same error.

Steps to Reproduce

  1. terraform init
  2. terraform apply

Important Factoids

Grafana instance is running on ECS Fargate and accessible for terraform environment.
Issue can also be reproduced with 1.5 Grafana provider version.

@charlottemach
Copy link

You have a semicolon between your username and password ;, instead of them being separated by a colon :, might make a difference.

@chorne-togetherwork
Copy link

Same issue, and as @neocorp said, using the API Token doesn't work either, and that does not require a colon or semicolon.

@shalyng
Copy link

shalyng commented Dec 30, 2019

Do you have basic_auth enabled? It seems username/password combo only works with basic_auth enabled.https://grafana.com/docs/grafana/latest/http_api/auth/#basic-auth

@chorne-togetherwork
Copy link

Mine was as simple as updating the url to use https, it seems. The semicolon may be part of the original issue, but v1.5 of the provider is also available, so I'm not sure if that would make a difference.

@neocorp
Copy link
Author

neocorp commented Jan 7, 2020

I've tried with colon, semicolon, added basic_auth_enabled flag and almost every possible combination but no luck. Mine is on https already and also tried with v1.5 of the provider, still no luck. Any help is really appreciated, I'd rather implement these datasources and dashboards with Terraform.

@neocorp neocorp changed the title Provider cannot connect to Grafana instance, throws 401 Unathorized Provider cannot connect to Grafana instance, throws 401 Unauthorized Jan 10, 2020
@pascal-hofmann
Copy link
Contributor

pascal-hofmann commented Apr 9, 2020

Maybe some of you are running into this issue: nytm/go-grafana-api#41

Took me a while to figure out, that colons (:) in passwords are not supported right now…

@mlclmj
Copy link
Contributor

mlclmj commented Apr 18, 2020

The colons-in-passwords issue was patched upstream (thanks @pascal-hofmann!) and will be included in the next release.

401 errors typically aren't the fault of the provider itself, though if there's other issues with how we're parsing/passing credentials that'd definitely be something to address

@tonglil
Copy link
Contributor

tonglil commented Jun 3, 2020

This should be fixed when a release of the provided is cut (see #97).

@inkel inkel self-assigned this Dec 21, 2021
@inkel
Copy link
Contributor

inkel commented Dec 22, 2021

Hi! Thank you for reporting this, and sorry for the long delay it took us to get back in touch.

After careful consideration we're going to close this one, as it refers to outdated versions of both the Grafana provider and Terraform itself.

If you continue to experience this issue please try again with the latest versions of both tools mentioned above, and otherwise reopen this issue.

Thanks for understanding.

@inkel inkel closed this as completed Dec 22, 2021
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

No branches or pull requests

8 participants