This function finds the address of the parent module of the module containing an item from its module_address
using the tfconfig/v2 import.
It does this by parsing module_address
which will look like "module.A.module.B" if the item is not in the root module or "" if it is in the root module.
This function is contained in the tfconfig-functions.sentinel module.
get_parent_module_address = func(module_address)
- module_address: the address of the module containing some item, given as a string. The root module is represented by "". A module with label
network
called by the root module is represented by "module.network". if that module contained a module with labelsubnets
, it would be represented by "module.network.module.subnets".
None.
This function returns a string containing the address of the parent module of the module represented by the module_address
parameter. If called against the root module of a Terraform configuration, it returns "root".
This function does not print anything.
Here is an example of calling this function, assuming that the tfconfig-functions.sentinel file that contains it has been imported with the alias config
:
module_address = r.module_address
parent_module_address = config.get_parent_module_address(module_address)