Hi guys
I’m trying to use an azure service principal account in terraform, I have set the $env for each variable within my powershell profile script, as stated here: Authenticate Terraform to Azure | Microsoft Docs
I have my provider setup as such:
# Configure the Microsoft Azure Provider
provider "azurerm" {
features {}
subscription_id = "${env.SUBSCRIPTION_ID}"
tenant_id = "${env.TENANT_ID}"
client_id = "${env.CLIENT_ID}"
client_secret = "${env.CLIENT_SECRET}"
}
However I’m receiving an error for each variable, like so:
│ Error: Reference to undeclared resource
│
│ on main.tf line 16, in provider "azurerm":
│ 16: client_secret = "${env.CLIENT_SECRET}"
│
│ A managed resource "env" "CLIENT_SECRET" has not been declared in the root module.
if I run $env:ARM_CLIENT_SECRET, it will output the password, so the global variable is set, but for some reason Terraform cannot see it. If I hard code the attributes into the provider it seems to work. Am I missing another setting for terraform to be able to see the $env variables?
I hope I explained that correctly, thanks.