mirror of
https://github.com/opentffoundation/opentf.git
synced 2025-12-25 01:00:16 -05:00
Static Evaluation Base, Module Sources, Backend Config (#1718)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com> Signed-off-by: Christian Mesh <cristianmesh1@gmail.com> Co-authored-by: James Humphries <James@james-humphries.co.uk> Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
This commit is contained in:
@@ -463,3 +463,28 @@ OpenTofu will still extract the entire package to local disk, but will read
|
||||
the module from the subdirectory. As a result, it is safe for a module in
|
||||
a sub-directory of a package to use [a local path](#local-paths) to another
|
||||
module as long as it is in the _same_ package.
|
||||
|
||||
## Support for Variable and Local Interpolation
|
||||
|
||||
As projects grow in complexity and requirements, it is prudent to consider using locals and variables in the module source and version fields.
|
||||
|
||||
Many organizations utilize the mono-repo pattern for modules:
|
||||
```hcl
|
||||
locals {
|
||||
modules_repo = "github.com/myorg/tofu-modules/"
|
||||
modules_version = "?ref=v1.20.4"
|
||||
}
|
||||
|
||||
module "storage" {
|
||||
source = "${local.modules_repo}/storage${local.modules_version}"
|
||||
}
|
||||
|
||||
module "compute" {
|
||||
source = "${local.modules_repo}/compute${local.modules_version}"
|
||||
}
|
||||
```
|
||||
It is quite easy to then update the version for a patch release, or to switch to a fork of the repository.
|
||||
|
||||
:::note
|
||||
The source and version fields may not contain any references to data in the state or provider defined functions. All value must be able to be resolved during `tofu init` before the state is available.
|
||||
:::
|
||||
|
||||
@@ -62,8 +62,7 @@ Module calls use the following kinds of arguments:
|
||||
All modules **require** a `source` argument, which is a meta-argument defined by
|
||||
OpenTofu. Its value is either the path to a local directory containing the
|
||||
module's configuration files, or a remote module source that OpenTofu should
|
||||
download and use. This value must be a literal string with no template
|
||||
sequences; arbitrary expressions are not allowed. For more information on
|
||||
download and use. For more information on
|
||||
possible values for this argument, see [Module Sources](../../language/modules/sources.mdx).
|
||||
|
||||
The same source address can be specified in multiple `module` blocks to create
|
||||
|
||||
Reference in New Issue
Block a user