tm_bundle(class, alias) β
Returns a single bundle object for the given class and key, or null if not found. The key can be either the bundle alias or the bundle UUID.
Syntax β
hcl
tm_bundle(class, key)Parameters β
class(string) - The bundle class identifier to query forkey(string) - The bundle alias or UUID to match
Return Value β
Returns a single bundle object or null if not found. The bundle object has the following schema:
hcl
{
class = string
alias = string
uuid = string
inputs = map(object) # access value as .inputs.<name>.value
exports = map(object) # access value as .exports.<name>.value
}Examples β
Access a bundle export β
hcl
locals {
api_endpoint = tm_bundle("example.com/my-bundle/v1", "main").exports.my_export.value
}Access a bundle input β
hcl
locals {
service_name = tm_bundle("example.com/my-bundle/v1", "main").inputs.name.value
}Select by UUID instead of alias β
hcl
locals {
config = tm_bundle(
"example.com/my-bundle/v1",
"5d5b9f5c-2b66-4a3c-8d0a-2a6f7b9e2c1a"
).inputs.configuration.value
}Handle missing bundles β
hcl
locals {
optional_config = try(
tm_bundle("example.com/optional-bundle/v1", "main").inputs.config.value,
"default-value"
)
}Related Functions β
- tm_bundles - Get all bundles of a given class
- tm_source - Translate module paths in components