-
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
Failed to install providers for proxied external providers, e.g. cloudflare #26448
Comments
Hi @ChristophShyper! It seems like you've already found the solution to this problem, which is to declare in your submodule that the local name From what you've said here it seems like you now have a working configuration, so I'm not sure what else remains to be done with this issue. Did you run into some other problem after you added that missing dependency declaration? |
So it's expected behaviour that only some providers can be proxied? Shouldn't that be mentioned in the documentation? |
I am running into the same issue and I tried the same solution but was unable to resolve it. Terraform version: 0.13.5 |
@nlloyd-invitae I believe you have a different issue here, the original author's issue is about a submodule that needed to be upgraded to 0.13, which they then did manually outside of the upgrade tool. Your issue sounds like you're talking about a local provider not being correctly identified -- it could be you also need to run the Could you open a separate issue if you're still having trouble, filling out the issue template with more information? |
@pselle my original issue isn't resolved. Proxied providers work only for Hashicorp's ones. I only found a workaround. Issue reported by @nlloyd-invitae looks almost exactly the same as mine. Terraform can find version of the provider, but cannot install it for whatever reason. |
Also the workaround that is working for @ChristophShyper is not working for me unfortunately.
Based on the configuration the first line should not be happening at all. |
@ChristophShyper as to documentation, perhaps https://www.terraform.io/docs/configuration/provider-requirements.html#names-and-addresses is what you're looking for on clarification on what addresses are? Specifically the note under https://www.terraform.io/docs/configuration/provider-requirements.html#source-addresses where |
@pselle I know it. It says |
Perhaps a point of confusion here is that you're passing provider configuration through the proxy providers block in the module call -- this is not equivalent to wholesale passing a provider. The |
Ok, this makes sense now. Can such information be added to documentation then? Because it's confusing why it works only sometimes. |
I found my mistake, the provider block was being defined in the parent module not the submodule, however the resources themselves were only being defined/used in the submodule. Moving the required_providers block and provider block into the submodule addressed the issue. |
@ChristophShyper I'll mark this issue as a documentation update, because it catches people pretty often. |
Thank you @pselle and @nlloyd-invitae for making it clear that provider "inheritance" for non-HashiCorp modules is broken.
Questions
|
Why is this not in the documentation? |
How does one solve the issue of @nlloyd-invitae for modules on the registry? You shouldn't have to redefine required_providers for the modules you call I think? |
Each module that refers to a provider must separately define a dependency for it, in its own Using the most recent comment for an example, if you are publishing a shared module that uses the terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = ">= 2.14.0"
}
}
} The above declaration tells Terraform that when declarations in the rest of the module refer to "cloudflare" that means As we've seen earlier in the discussion, this is something separate from providing a configuration for that provider. The module we're discussing will presumably also contain at least one resource whose type belongs to the resource "cloudflare_zone" "example" {
zone = "example.com"
} This is a situation where Terraform has some implied behavior to keep things concise but where as a result it might be hard to follow what's going on. The implied behavior is that Terraform sees the resource "cloudflare_zone" "example" {
provider = cloudflare
zone = "example.com"
} The The remaining missing piece then is to write out the default (unaliased) configuration for the terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = ">= 2.0.0"
}
}
}
provider "cloudflare" {
account_id = "abc123"
} Again, the Declaring such a provider therefore satisfies the needs of that child module, due to the automatic inheritance behavior for default provider configurations. However, we can also write it out explicitly to see what's really going on: module "example" {
source = "../shared-module-example"
providers = {
cloudflare = cloudflare
}
} The Such a All of what I've said above is covered by text somewhere in the documentation, but I can see that the current organization of the documentation makes it hard to absorb all of this information together and understand the full system. I'm not sure yet how better to organize it, but the work to figure that out is what this issue already represents. I expect a big contributor to the lack of clarity here is the existing design of aliased provider configurations and proxy provider configurations, which isn't actually a new thing in v0.13 -- it was added back in v0.11 -- but it's got enough confusing and implied behavior to make it hard to follow what exactly it's doing, which then has the knock-on effect of making it harder to understand how it interacts with provider requirements. A new design for passing around provider configurations isn't in scope for this issue but it's an item on the list for longer-term design work. In the meantime, I hope the above example helps to connect the parts together to understand the overall model. |
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. |
Terraform Version
Terraform Configuration Files
./main.tf
:./submodule/main.tf
:Debug Output
Crash Output
Expected Behavior
Proxied external providers (not the ones from
hashicorp/...
should work the same as the hashicrop's ones) should be passed properly and just work.Actual Behavior
It fails the validation, because provider is not passed properly to submodules.
Steps to Reproduce
Additional Context
If I add
required_providers
just forcloudflare
it starts to work../submodule/main.tf
:References
The text was updated successfully, but these errors were encountered: