Terraform -> Warning: Value for undeclared variable

2.9k Views Asked by At

I get the following warning in terraform cloud which is connected to azure. How can i resolve this error ?

Thanks a lot

error

1

There are 1 best solutions below

0
Martin Atkins On

This warning is asking you to decide between the following options:

  1. Add a variable "ARM_CLIENT_ID" block and a variable "ARM_TENANT_ID" block to your root module to declare each of these input variables.
  2. Remove ARM_CLIENT_ID and ARM_TENANT_ID from the input variables you've defined in the Terraform Cloud workspace settings, if they are not needed at all.
  3. Instead of setting these as input variables, instead set them as environment variables named TF_VAR_ARM_CLIENT_ID and TF_VAR_ARM_TENANT_ID so that Terraform will just ignore them if there isn't any declaration.

However, I think this warning message is misleading you in this case because I think Terraform has misunderstood what you intended to do and is therefore suggesting solutions that don't make sense for what you intend to do.

I happen to know that ARM_CLIENT_ID and ARM_TENANT_ID are environment variable names that the hashicorp/azure provider will use, and so I expect that you don't intend them to be Terraform variables at all, and were instead trying to set the environment variables for the provider.

If that's true, then I suggest you first carry out the option 2 I mentioned above -- removing the declarations of those variables altogether. But then in addition to that, also add Environment Variables (which are separate from Terraform Variables) for ARM_CLIENT_ID and ARM_TENANT_ID in the Terraform Cloud workspace settings.

By doing these two steps you should first quiet this warning but then separately you'll also give the Azure provider what it needs to work. If you only do my option 2 above without also adding the environment variables then you will quiet the warning but instead see an error from the hashicorp/azurerm provider that it isn't properly configured.