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
Discussion - Compositional Limits / Improvements #7937
Comments
Hi @robrankin! The [list and map] types which are now available as module-level variables are the start of work to support situations similar to this one, however I think they will need more work to complete. Examples such as this are useful for guiding this so thank you for opening this issue! Something that is perhaps not well documented, and is probably unclear unless you are familiar with the source for HCL, the language from which it is derived (UCL), or the source for the specific resource in question is that multiple Consequently I'm going to leave this issue open - if others have additional examples of how they would like to use the module system we are certainly open to hearing those and considering them as part of future design. Thanks! |
In the Azure RM world Does that distinction exist in TF at all? Or are the various configuration arguments of a resource essentially the equivalent of a sub-resource (or nested resource)? Currently some of the configuration override/adding/changing I want to accomplish can be done with sub resources if they're exposed as top level resources (i.e. see virtual networks and subnets), but even then the normal resource arguments of that aren't exposed. If the nested resources work would expose the resources arguments as resources that can managed separately, that might do the trick for me. p.s I tried passing lists of maps into various resources and using them with arguments, and it causes all sorts of funky error messages 😄 i.e. |
Terraform 0.12 is the start of having a more composable language and we'll continue to improve it over time. |
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. |
Limitations
The Module pattern allows for a certain amount of code reuse, but there are still limits, specifically surrounding sub-resources and resource configuration blocks and changing/overriding those.
Assume a setup as such:
Example 1 - Base VM Resource, Linux, no data disks
This resource is only usable as a Linux VM with no data disks attached.
You cannot use an override file here, as that override file is applied whenever you use this base resource in a module (i.e. the override file exists in the base resource directory, therefore it is applied when the module sources the base resource directory)
I’d like to be able to use the following base VM template, and then add to that using modules (or some other agreed approach), as detailed in Example 2.1 / 2.2
Example 2.1: Base VM Resource, no data disks, no specific OS config
Setup now more generic (no linux specificity), as such:
Example 2.2 - Extract Linux OS Config with multiple data disks below.
I’d then like to be able to alter the underlying template sourced by a module. This example can add the OS specific os_profile_linux_config, and it can add additional config for the data disks.
Basically, I’d like modules to be able to apply some form of overrides to the resource they are sourcing. Syntax and approach completely open for debate, above examples simply used to try and highlight what I’d like to see.
Is there anything like this available today, or being planned?
The text was updated successfully, but these errors were encountered: