Open jameswestall opened 3 years ago
Hi @jameswestall This is not a ADO provider issue. You should define the variables in child module too, you can reference this post: https://discuss.hashicorp.com/t/accessing-variables-declared-and-defined-in-parent-from-child-module/10462/6
Working configuration is :
org_service_url
and personal_access_token
to demo-module-usage
configure block:
module "demo-module-usage" {
...
org_service_url = var.org_service_url
personal_access_token = var.personal_access_token
}
org_service_url
and personal_access_token
in variables.tf
and reference the root module's configuration
//link to root module configuration
variable "org_service_url" {
description = "Name of the VPC"
}
variable "personal_access_token" { description = "Private IP block for the VPC in CIDR format" }
//provider configure provider "azuredevops" { org_service_url = var.org_service_url personal_access_token = var.personal_access_token }
@xuzhang3 - I'm not sure if you're correctly understanding the problem I've described. What I'm experiencing is not aligned to the Terraform documentation and expected behaviour. From the provider documentation:
"Provider configurations, unlike most other concepts in Terraform, are global to an entire Terraform configuration and can be shared across module boundaries"
See here for implicit inheritance guidance: https://www.terraform.io/docs/language/modules/develop/providers.html#implicit-provider-inheritance
Removing the module for DevOps resources also fixes this issue, however this means we are not allowed to create standardised modules for resources.
@jameswestall I get your point, I need more investigation on this issue.
Hey there @xuzhang3 - Not to rush you on this issue, is there anything I can help with collection for diagnosis?
hi @jameswestall This issue is still under investigation. ADO read personal_access_token
and org_service_url
from environment configurations. As -var
can pass the configurations and ADO can find it, I assume this variables are set to the Terraform context session. The problem is sub modules cannot get these configuration, we need to figure out if this is an ADO provider issue or Terraform forbidden to do this.
I am having similar/same issue to #239 since terraform upgrade from 0.13 to 0.14.6
I am entirely unable to use variables in the provider configuration WHEN using custom modules which hold Azure DevOps resources.
TF Version
Steps to reproduce
Error Example
Post removal of pat and url variables within the Azure DevOps provider, this nested module begins to function.
Functioning Output