-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Terraform does not pass provider options (subscription_id at least) to a child module #28066
Comments
Here is a workaround to do what the ### replace in ./main.tf
[...]
module "test" {
source = "./test"
other_subscription_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # <= subscription different from the default subscription
}
[...] ### replace in ./test/main.tf
[...]
variable "other_subscription_id" {
}
provider "azurerm" {
alias = "other"
subscription_id = var.other_subscription_id
features {}
}
[...] |
Hi @esciara Thanks for filing the issue. The confusing nature of this behavior was made worse by the fact that it occasionally did work, because part of the code path did not expect multiple different provider configurations at that point. The lack of validation here was an oversight, and is fixed by #27739 as part of the 0.15 release. Thanks! |
Thanks for your reply @jbardin . When I remove the provider configurations in the module, I get the following error message:
So does that mean that it will never work on 0.14? Or am I doing something wrong? As a note, this error message appears despite having made sure that there are |
In 0.14 you will still ned to use a proxy provider block as a placeholder for the provider name. |
@jbardin Thanks for the link. It made me tic! The problem was that I had a So by replacing: ### ./test/main.tf
provider "azurerm" {
features {}
}
provider "azurerm" {
alias = "other"
features {}
}
[...] with simply: ### ./test/main.tf
provider "azurerm" {
alias = "other"
}
[...] It all works. Thanks. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
It should be possible to pass providers explicitly to modules, but this fails in the example below with the
azurerm
provider, where thesubscription_id
is not passed with the provider to the module.Terraform Version
Terraform Configuration Files
Debug Output
N/A
Crash Output
N/A
Expected Behavior
On
terraform apply
, the data sourcedata.azurerm_resource_group.rg_in_other_subscription_2
should be found andterraform
should exit without issues.Actual Behavior
On
terraform apply
, output is:And indeed, when looking in the Azure Portal, the resource group
rg-in-other-subscription-2
has been created in the default subscription (in my case the subscription set through the azure cli).Steps to Reproduce
terraform init
terraform apply
Additional Context
N/A
References
N/A
The text was updated successfully, but these errors were encountered: