rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 216 forks source link

[BUG] Providing API key and secret through environment variables doesn't work #1283

Open OzoneChris opened 6 months ago

OzoneChris commented 6 months ago

Rancher Server Setup

Information about the Cluster

User Information

Provider Information

Describe the bug

Providing credentials to the provider via RANCHER_ACCESS_KEY and RANCHER_SECRET_KEY per the provider docs results in a error while planning:

Error: [ERROR] No token_key nor access_key and secret_key are provided

To Reproduce

terraform {
  required_providers {
    rancher2 = {
      source  = "rancher/rancher2"
      version = "3.2.0"
    }
  }
  required_version = ">= 1.5.0"
}

provider "rancher2" {
  api_url = "https://${var.rancher_server_dns}"
  timeout = "300s"
  #   access_key = var.rancher2_access_key
  #   secret_key = var.rancher2_secret_key
}

Tested locally like this:

$ terraform --version
Terraform v1.6.6
on linux_arm64
+ provider registry.terraform.io/hashicorp/aws v5.31.0
+ provider registry.terraform.io/hashicorp/local v2.4.1
+ provider registry.terraform.io/rancher/rancher2 v3.2.0
$ env | sort | grep RANCHER
RANCHER_ACCESS_KEY=123
RANCHER_SECRET_KET=456
$ terraform plan

Actual Result


Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: [ERROR] No token_key nor access_key and secret_key are provided
│ 
│   with provider["registry.terraform.io/rancher/rancher2"],
│   on providers.tf line 21, in provider "rancher2":
│   21: provider "rancher2" {

Expected Result

Tested with the same credentials passed as variables to access_key and secret_key works as expected, planning and applying configuration successfully.