terraform-provider-nsxt
terraform-provider-nsxt copied to clipboard
Environment variable based authentication not working
Hi folks, For some odd reason I can't get auth to work using environment variables on a linux box. This "linux box" part is important as this works just fine on my Mac.
2021-11-29 19:10:52|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> echo $NSXT_USERNAME
<snip for privacy>
2021-11-29 19:18:15|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> echo $NSXT_PASSWORD
<snip for privacy>
2021-11-29 19:18:19|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> terraform refresh
╷
│ Error: username must be provided
│
│ with provider["registry.terraform.io/vmware/nsxt"],
│ on main.tf line 16, in provider "nsxt":
│ 16: provider "nsxt" {
│
╵
2021-11-29 19:18:28|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> cat main.tf
terraform {
backend "consul" {
address = "consul.service.rch1-dc.consul"
scheme = "http"
path = "NETENG/terraform/nsxt-infra/nsx6101/main.tfstate"
gzip = true
}
required_providers {
nsxt = {
source = "vmware/nsxt"
version = ">= 3.2.3"
}
}
}
provider "nsxt" {
host = var.nsx_manager_fqdn
}
2021-11-29 19:18:33|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$>
I removed the actual variable values for the purposes of bug report, but they do contain a valid username and password.
2021-11-29 19:18:33|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> uname -a
Linux bastion61000 3.8.13-118.20.2.el6uek.x86_64 #2 SMP Sun Jan 28 10:51:54 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
2021-11-29 19:22:08|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> terraform --version
Terraform v1.0.11
on linux_amd64
+ provider registry.terraform.io/vmware/nsxt v3.2.4
2021-11-29 19:22:55|<snip for privacy>@bastion61000:~/git/nsxt-terraform/environments/RCH1 (production)
$> cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
Hi @akhomyakov, I just double-checked, and env variables are working fine for me on linux. This is implemented via pretty basic functionality so its hard to imagine what could go wrong here.. https://github.com/vmware/terraform-provider-nsxt/blob/6b49e6799892687bc04d1c31d4b05c03e95ea8da/vendor/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema/schema.go#L272
I'm curious whether it would work if you provided those variables via terraform variables (via command line) that would be populated by same environment variables?
Hi I didn't forget about this. It just went onto the back burner. The reason I ended up doing this on a linux box is no more, so investing time into investigating this problem is no longer a work priority for me and I must find personal time to do a few tests. I'll post the update when I get to actually test out providing credentials as terraform variables rather than shell environment variables. -Andrey
Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.
If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!
Andrey, please reopen if still relevant