-
Notifications
You must be signed in to change notification settings - Fork 910
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
Allow for variables inside of required_providers
blocks
#1850
Comments
Hello and thank you for this issue! I understand that this issue has already been discussed in Slack. |
A somewhat-hairy issue to contend with for allowing dynamic substitution into Allowing it for
I don't think either of these are insurmountable problems, but they do represent two additional hazards that have not been true for any of the locations where we've supported static evaluation so far, and I expect we'll need to think carefully about how OpenTofu could detect the above problems in a way that allows returning a relevant and actionable error message, rather than something highly confusing. |
Thanks for the insightful response here, I'd like to clarify from a Tofu DX perspective what kind of use case I'd see for this issue in particular. In OpenTofu, there's an implied best practice for creating child modules, and that's if you are creating child modules (by this I am referring to modules that you intend to not be root modules, but library components that you intend to be consumed by others in root modules) it's implied in the documentation that your The problem with this approach is, even if you know the minimum feature set your module requires by the provider, there is no way to ascertain forward compatibility without being able to test new provider versions in an automated way. It's very common that providers introduce breaking changes in minor versions, and strict semver adherence in the provider ecosystem is anemic to say the least. That being said, this would be a way for us to avoid having to create extremely verbose test scaffolding that instantiates child modules with a ton of different provider versions, and instead, have a single module where version is parameterized, and be able to create a CI jobs for each version of it's respective providers. I think that aligns with the prospect of maybe an easier implementation of passing specifically a providers version as a variable, instead of the entire |
OpenTofu Version
Use Cases
The use cases for this are pretty broad but the primary focus is:
Attempted Solutions
There has been a lot of discussion about this in Slack, there isn't really an alternative to this currently. If you want to do anything dynamically with a
required_providers
block, you have to do code-gen or HCL abstraction level golang libraries likehclwrite
as described in this blog post.So, the few alternatives that are...not great and a bit hacky are:
jq
to generate providers in jsonhclwrite
golang library as mentioned aboveProposal
This will allow you to do the following:
References
Open Questions
area of this RFC https://github.com/opentofu/opentofu/blob/main/rfc/20240513-static-evaluation-providers.md#open-questionsThe text was updated successfully, but these errors were encountered: