terradart_core
Core runtime for TerraDart — a Dart-first infrastructure-as-code 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 (final class MyStack extends Stack), registerResource/Datainstances viaadd(...)/addData(...), and callstack.writeTo('tf-out')from your ownmain()to emitmain.tf.json.Resource/Data— typed nodes supplied by provider factory packages.TfArg.literal(...)/TfArg.ref(...)/TfArg.variable(...)/TfArg.expression(...)— the four ways every settable field accepts input: a Dart value, a reference to another resource's attribute, a Terraform input variable, or a raw Terraform expression emitted verbatim (TfArg.expression(r'${lower(var.name)}-x')).TfArg<MyEnum>.literal(MyEnum.foo)encodes typed Dart enums (see below).LifecycleOptions—create_before_destroy,prevent_destroy,ignore_changes,replace_triggered_by.Stack.synth()returns an in-memorySynthResultwithtfJson(Terraform JSON map) and optionaldartConstants(typed Dart constants for the IaC ↔ application seam).Stack.writeTo(outDir)is the file-IO wrapper that callssynth()and writesmain.tf.json(plus anydartConstants) underoutDir.
This package is the runtime layer only. It is intentionally small and dependency-free.
Companion packages
| Package | Description |
|---|---|
terradart_google |
Curated factory wrappers for Google Cloud resources (hashicorp/google). |
terradart_google_beta |
Curated factory wrappers for beta-only Google Cloud resources (hashicorp/google-beta). |
terradart_appwrite |
Curated factory wrappers for Appwrite resources (appwrite/appwrite). |
terradart_cloudflare |
Curated factory wrappers for Cloudflare resources (cloudflare/cloudflare). |
terradart_agent |
MCP server (terradart-mcp) exposing the curated factory catalog to AI agents. |
terradart_codegen |
Maintainer generation tooling and CLI (terradart wrap). |
For project-level documentation, see the terradart repo README and terradart.dev.
Installation
dependencies:
terradart_core: ^0.28.x
Check pub.flutter-io.cn for the latest patch. Read MIGRATING.md before minor bumps.
Typed enum serialization
Hand-rolled and wrap-emitted enums implement TerraformEnum with a terraformValue getter. TfArgLiteral.toTfJson() encodes them to Terraform strings; missing conventions throw ArgumentError at synth time.
enum RoutingMode implements TerraformEnum {
regional('REGIONAL'),
global('GLOBAL');
const RoutingMode(this.terraformValue);
@override
final String terraformValue;
}
Libraries
- terradart_core
- terradart — Dart-first IaC runtime.