terradart_core
Core runtime for terradart — a Dart-first authoring layer for Terraform that produces drop-in main.tf.json for the standard terraform CLI.
This package ships the small set of primitives every terradart Stack uses:
Stack— abstract base for your infrastructure module. You subclass it, registerResource<S>/Data<S>instances viaadd(...)/addData(...), and callStackSynth.synth(this)from your ownmain().Resource<S>/Data<S>— typed nodes whose genericSis a schema carrier supplied by curated factories (interradart_google) or generated bindings (fromterradart_codegen).TfArg.literal(...)/TfArg.ref(...)— the only two ways every settable field accepts input.TfArg<MyEnum>.literal(MyEnum.foo)now encodes typed Dart enums (see below).LifecycleOptions—create_before_destroy,prevent_destroy,ignore_changes,replace_triggered_by.StackSynth.synth(stack)returning aSynthResultwithtfJson(Terraform JSON map) and optionaldartConstants(typed Dart constants for the IaC ↔ application seam).
This package is the runtime layer only. It is intentionally small and dependency-free. The companion packages are:
terradart_codegen— the codegen /terradartCLI that turnsterraform providers schema -jsoninto typed Dart bindings.terradart_google— 28 curated GCP factory wrappers + 1 data source, plus generated schema carriers.
For project-level documentation, see the terradart repo README.
Typed enum serialization
TfArgLiteral.toTfJson() detects values that satisfy a small convention and serializes them to the Terraform string:
enum RoutingMode {
regional('REGIONAL'),
global('GLOBAL');
const RoutingMode(this.terraformValue);
final String terraformValue;
}
// In your Stack:
GoogleComputeNetwork(
localName: 'main',
name: TfArg.literal('main-vpc'),
routingMode: TfArg.literal(RoutingMode.regional), // encodes to "REGIONAL"
);
The runtime throws ArgumentError (not silent wrong-output) if you pass an enum value whose type does not implement the .terraformValue getter, so missing-getter bugs surface at synth time rather than as bad Terraform JSON. String / int / num / bool literals pass through unchanged.
terradart_google 0.1.0-dev uses this convention for every fixed-value-set field in its 28 curated resources.
Installation
terradart is a SemVer pre-release. By default dart pub get skips pre-release versions; opt in explicitly:
dependencies:
terradart_core: ^0.1.0-dev
Libraries
- terradart_core
- terradart — Dart-first IaC runtime.