moduleGroup static method
Top-level module { ... } group, keyed by the call's local name:
source (and version) first, then the module's inputs, then the
meta-arguments. Returns null when the stack registers no call.
The module's own body is never read — a module block is a reference,
and Terraform resolves ModuleCall.source relative to the directory
the Stack synthesizes into.
Implementation
static Map<String, dynamic>? moduleGroup(Stack stack) {
if (stack.modules.isEmpty) return null;
final out = <String, dynamic>{};
for (final m in stack.modules) {
final block = <String, dynamic>{'source': m.source};
if (m.version != null) block['version'] = m.version;
block.addAll(encodeArgMap(m.inputs));
if (m.providers.isNotEmpty) {
block['providers'] = {
for (final MapEntry(:key, :value) in m.providers.entries)
key: providerReference(value),
};
}
final count = m.count;
if (count != null) block['count'] = encodeArg(count);
final forEach = m.forEach;
if (forEach != null) block['for_each'] = encodeArg(forEach);
final deps = m.dependsOn;
if (deps != null) {
final dep = dependsOn(deps);
if (dep != null) block['depends_on'] = dep;
}
out[m.localName] = block;
}
return out;
}