kevholditch / terraform-provider-kong

kong provider for terraform
MIT License
178 stars 91 forks source link

KONG_ADMIN_TOKEN ignored #135

Closed tlu-rs closed 2 years ago

tlu-rs commented 3 years ago

With v6.2.0 and v6.0.2, KONG_ADMIN_TOKEN is ignored. As a workaround we set KONG_API_KEY=${KONG_ADMIN_TOKEN} to get this to work.

Versions

Terraform v1.0.4 Kong Provider v6.2.0 and v6.0.2 Kong Enterprise v2.5.0.1

Terraform Configuration Files

export KONG_ADMIN_TOKEN=<redacted>

provider "kong" {
  kong_admin_uri = "https://${data.terraform_remote_state.kong.outputs.api_addr}/${var.domain}"
}

resource "kong_service" "service" {
  host     = "kong-test.example.com"
  name     = "kong-test"
  path     = "/"
  port     = 443
  protocol = "https"
}

Error

│ Error: failed to create kong service: &{<nil> 0xc000045180 <nil> 0xc0001dd480 <nil> 0xc0001dd400 0xc0001dd4e0 0xc000045168 0xc0001dd440 0xc0000451a0 0xc000045170 <nil> <nil> 0xc000045190 [] <nil> <nil> []} error: HTTP status 401 (message: "Invalid credentials. Token or User credentials required")

Workaround

export KONG_ADMIN_TOKEN=<redacted>
export KONG_API_KEY=${KONG_ADMIN_TOKEN}

Shouldn't this be opt.AdminToken instead of opt.APIKey like this?

    if opt.AdminToken != "" {
        headers = append(headers, fmt.Sprintf("kong-admin-token:%v", opt.AdminToken))
    }
kevholditch-f3 commented 2 years ago

Thanks for raising, this has been fixed in version v6.4.0