Bundle Definition β
A Bundle is defined using a define bundle {} block. One bundle per directory.
Sections to define β
- Metadata
- Alias
- Inputs
- Scaffolding
- Stacks
- Components in stacks
- Exports
Metadata β
hcl
define bundle metadata {
class = "example.com/my-bundle"
version = "1.0.0"
name = "My Bundle"
description = <<-EOF
My first Terramate Bundle is doing great things
EOF
# Optional
technologies = ["aws", "terraform"]
}Alias β
alias provides a unique identifier for bundle instances (per class) and is typically derived from inputs.
hcl
define bundle {
alias = tm_slug(bundle.input.name.value)
}Default alias: {bundle-instance-dirname}:{name}.
Inputs β
hcl
define bundle {
input "name" {
type = string
description = "Set a name for the service"
prompt = "Name of the Service"
required_for_scaffold = true
}
input "visibility" {
type = string
description = "Visibility of the Resource"
default = "private"
prompt = "Visibility"
allowed_values = [
{ name = "A public resource", value = "public" },
{ name = "A private resource", value = "private" },
]
}
}Notes β
- Supported types:
string,number,any,list(...),map(...). (Terraformβstyleobjectis not supported.) prompt,allowed_values,multiselect,multiline,required_for_scaffoldare used byterramate scaffold.required_for_scaffold(boolean): include this input in the interactive scaffold flow and require a value.
Scaffolding β
hcl
define bundle scaffolding {
path = "/path/to/bundle_${tm_slug(bundle.input.name.value)}.tm.yml"
name = tm_slug(bundle.input.name.value)
}Controls where the instantiation file is written and its default name.
Stacks β
hcl
define bundle stack "organization-members" {
# Optional: conditionally include this stack
condition = <bool expression>
metadata {
path = "organization/memberships"
name = "GitHub Organization Member"
description = "GitHub organization members, owners, collaborators and blocked users"
tags = ["example.com/github-organization"]
# Optional: additional metadata
after = []
before = []
wants = []
wanted_by = []
watch = []
}
component "members" {
source = "/components/terramate.io/terramate-tf-github-organization-members/v1"
inputs = { for k in tm_keys(bundle.input) : k => bundle.input[k].value }
}
}Stack metadata supports: path, name, description, tags, after, before, wants, wanted_by, watch (relative path is resolved from instantiation file; absolute is from repo root).
Behavior β
- Stacks are created if missing.
- On existing stacks,
nameanddescriptionare only set if empty; list fields (tags,after,before,wants,wanted_by,watch) are merged (union). - Removing a bundle instantiation removes generated code but not the stack itself.
Available bundle context β
bundle.inputβ access input values, e.g.bundle.input.name.valuebundle.classβ the bundle class (from metadata)bundle.uuidβ the unique instance UUID (useful for tagging and crossβbundle relationships)
Scaffolding β
hcl
define bundle scaffolding {
path = "/path/to/bundle_${tm_slug(bundle.input.name.value)}.tm.yml"
name = tm_slug(bundle.input.name.value)
enabled {
condition = <bool expression>
error_message = "Shown when condition is false"
}
}path/name: controls output location and default instance name used byterramate scaffold.enabledblocks: optional gating for whether a bundle is selectable in the scaffold UI. When theconditionevaluates to false, the bundle is disabled anderror_messageis shown.
Exports β
hcl
define bundle export "team_tuple" {
value = [bundle.input.parent.value, bundle.input.name.value]
}Exports make precomputed values available to other bundles or code generation (e.g., for allowed_values).
Related guides and references β
- Concepts: Bundles
- Reference: Component Definition