Share
Embed
What I thought while building Dart IaC
Slides about Terradart, a full-stack Dart IaC I build on my own, and what I thought about while building it.
Terradart: https://terradart.dev
GitHub: https://github.com/nozomi-koborinai/terradart
Nozomi Koborinai
November 29, 2026
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
26 slides
-
Summary I've built Terradart around its public interface 01 Why
I built it 02 What I care about 03 4 decisions along the way Full-stack Dart IaC Public interface design Type, API, and CLI design • After UI, servers, and AI, • Leave internals to AI and focus write cloud infra in Dart too • Generated infra.g.dart connects it to the app type-safely → on designing the visible parts → Sensitive<T> sealed class OpenTofu dart install • Easy for AI to use, and easy for a person to check at the end In Terradart, I build a public interface that AI can work with and people can check at the end 2 -
Agenda 01 Why I built it 02 What I care
about while building it 03 Decisions I made while building Terradart 04 Summary 3 -
01 Why I built it Server-side Dart is growing in
Google's official products, too Cloud Functions for Firebase Server logic in Dart (announced April 2026 Experimental Genkit Dart Stable 1.0 Server-side AI logic in Dart too Sources: firebase.blog/posts/2026/05/dart-functions-exp/ / flutter.dev/blog/whats-new-in-flutter-350 5 -
01 Why I built it Infrastructure was the one thing
you still couldn't write in Dart Written in Dart Infra UI Server AI Flutter Cloud Functions Genkit Dart Serverpod / Dart Frog, etc. Terraform / Pulumi CLI / console I decided to build IaC that lets you write cloud infra in Dart too 6 -
01 Why I built it CDK for Terraform CDKTF) has
been archived HashiCorp's official CDKTF: development ended Dec 10, 2025; archived Nov 2026 Official README Sunset Notice): "did not find product-market fit at scale" (github.com/hashicorp/terraform-cdk) 7 -
01 Why I built it I won't make it just
a wrapper for existing IaC If it only replaced HCL with Dart Theme: Full-stack Dart • For infrastructure-only config, AI can just write HCL directly • Write infra and app in the same Dart • The app still gets plain strings, so types don't carry over • There's little reason to use it from Dart, so I thought it would soon go unused • The compiler checks references and options between resources • Values output by the infra reach the app type-safely 8 -
01 Why I built it What Terradart does 1 2
Write the config in Dart ••• infra/lib/stack.dart 3 Run terradart apply ••• Cloud resources are created infra/ $ terradart apply --env dev final api = add(GoogleCloudRunV2Service( 'api', name: .literal('${env.name}-api'), location: .literal('asia-northeast1'), template: CloudRunV2ServiceTemplate( containers: [.new(image: .literal(apiImage))], ), )); addOutput('api_url', api.uri); addDartDefineOutput(); → ✓ synth Terraform JSON and infra.g.dart ✓ plan + apply applied with OpenTofu / Terraform Cloud Run dev-api asia-northeast1 → ✓ outputs writes dart_defines.dev.json api.uri https://dev-api-3k7q2xw5ra-an.a.run.app Google Cloud / AWS / Azure / Cloudflare / Appwrite 4 5 Outputs are written to a file ••• { } ••• infra/.terradart/dart_defines.dev.json → lib/generated/infra.g.dart // a typed getter per output String get apiUrl my_app News → ••• Calls the API lib/main.dart const infra = AppStackOutputs.fromDartDefine(); final res = await http.get( Uri.parse(infra.apiUrl).resolve('/news')); "API_URL": "https://dev-api-3k7q2xw5ra-an.a.run.app" ••• 6 The app reads them my_app/ $ flutter run \ /-dart-define-from-file=infra/.terradart/dart_defines.dev.json New menu items Scheduled maintenance Weekend sale 9 -
01 Why I built it Stack: a Dart class that
describes infrastructure ••• INFRA infra/lib/stack.dart ••• AppStack({required Env env}) providers: [GoogleProvider(project: env.projectId)], lib/main.dart import 'generated/infra.g.dart'; final class AppStack extends Stack { : super( APP const infra = → AppStackOutputs.fromDartDefine(); appExports: AppExports('/./lib/generated/infra.g.dart'), // outputs become type-safe getters ) { Text('Events: ${infra.eventsTopicId}') final topic = add(GooglePubsubTopic( 'events', name: .literal('${env.name}-events'), )); addOutput('events_topic_id', topic.id); addDartDefineOutput(); } } • Extend Stack and add() resources • terradart apply generates infra.g.dart • Rename an output, and flutter analyze shows where it's read 10 -
02 What I care about while building it I focus
on designing the public interface Internals (not visible from outside) Public interface (visible from outside) • I used to fine-tune package internals, • Web API endpoints, classes, arguments, down to how functions were split CLI commands, generated code: I spend time and how helpers were named on the boundaries users and AI touch directly • Now AI writes more of the internals, so I leave the details to it • I care about connecting clearly with other frameworks and libraries 12 -
02 What I care about while building it Terradart's public
interface Dart classes and methods CLI commands and flags API for writing infrastructure Used by people and AI alike Stack / add() / addOutput() terradart plan /-json Generated infra.g.dart Error messages Outputs the app reads Include how to fix it infra.eventsTopicId SensitiveLiteral 13 -
02 What I care about while building it The public
interface is how people and AI find out how to use it Public interface Types add() / addOutput() / variable Generated accessors AppStackOutputs.fromDartDefine() → CLI and errors $ terradart --help Pass sensitive: true to addOutput Human ← AI Docs README / terradart.dev / llms.txt AGENTS.md, terradart skill Internals 14 -
02 What I care about while building it As tools
and libraries keep growing, I prioritize a clear public interface • More people build with AI, and new New GitHub repositories (per month) 30.3 million 2x the previous year tools and libraries keep appearing • If the README or public interface is unclear, people and AI burn time and tokens going → back and forth before even trying it GitHub Octoverse 2026 My approach * Total count, including private and experimental repos I want the README and public interface to be clear It's hard to try everything in depth, so Data period 20251001 to 20260930. Sources: github.blog Octoverse 2026, simonwillison.net/2026/Oct/28/github-octoverse-2026/ 15 -
02 What I care about while building it I care
about making the final human check easy Cut noise before a person looks Keep the interface human-readable Even if AI does most of the work, the final call If the public interface is simple on changing production infra stays with people. and readable by people, then even I want typos and needless errors stopped by when AI does the work, you can see automated checks before a person approves what changes and decide yourself Human review and approval take the most time. I want API design and automated checks to ease that 16 -
03 Decisions I made while building Terradart Which layers ensure
quality before human review cost Lauren Tan (poteto) 1 Codebase From the talk "All Code Is Slop Except Mine)" Public interface, internals, architecture 2 Static checks 1 2 Codebase and static checks Lint, types, compiler, tests Decided by programs, same every time 3 Verification Runtime and formal verification • The further down, the higher the time and human cost 4 Docs Rules, Skills, AGENTS.md • The less human review at the tip, the more stable development gets Human review ▼ Source: Lauren Tan (poteto), "All Code Is Slop Except Mine)" / AI Engineer CODE 2026 youtube.com/watch?v=O_zcc6Xl12g 18 -
03 Decisions I made while building Terradart "Codebase and static
checks" for Flutter/Dart engineers 1 Codebase Same shape, whoever writes it Add resources in the Stack class with add() and addOutput() 2 Static checks Automated checks you run from the CLI PLAN $ terradart plan /-env dev # google_pubsub_topic.events will be created + resource "google_pubsub_topic" "events" { + name = "dev-events" + project = "my-app-dev" } # google_pubsub_subscription.worker will be created + resource "google_pubsub_subscription" "worker" { + name = "dev-worker" + topic = "dev-events" } Plan: 2 to add, 0 to change, 0 to destroy. Dart types, dart analyze, terradart validate, --json output and exit codes for AI and CI What a person checks last is this plan diff 19 -
03 Decisions I made while building Terradart I've made 4
decisions in Terradart 1 Sensitive<T> prevents hardcoded secrets 2 Mutually exclusive arguments become one sealed class 3 OpenTofu as the default execution engine 4 CLI installable with dart install Types and API / Secrets Types and API / Arguments CLI / License CLI / Install experience 20 -
03 Decisions I made while building Terradart 1 Sensitive<T> prevents
hardcoded secrets Passwords stay out of the code DART dbPassword holds only a variable name Keep them in GitHub secrets, Secret Manager, etc., and pass them in at apply time Hardcoding is a compile error password: is a Sensitive<String>. There's no .literal(), so you can't write a string Lower the risk of leaks to the client final dbPassword = variable<String>( 'db_password', sensitive: true, ); // It only holds the variable name db_password. // No password string is stored here add(GoogleSqlUser( 'app', instance: primary.ref, name: .literal('app'), password: dbPassword, // password: .literal('//.') is a compile error )); Even with a Flutter app in the same repo, the code holds no secrets, so there's less worry about leaks via bad commits or app analysis Pass it in at apply time $ terradart apply /-env dev /- -var "db_password=$DB_PASSWORD" 21 -
03 Decisions I made while building Terradart 2 Expressing either-or
arguments as types HCL Terraform resource "google_firebase_hosting_channel" "preview" { TERRADART terradart_google_beta GoogleFirebaseHostingChannel( provider = google-beta 'preview', site_id = "my-site" siteId: .literal('my-site'), channel_id = "preview" channelId: .literal('preview'), ttl = "86400s" expiration: .ttl(.literal('86400s')), expire_time = "2026-12-01T00:00:00Z" } // .ttl or .expireTime, only one ) Both can be written, and you only Only one can be written, and it's caught notice after running the CLI in the IDE and at compile time This either-or is expressed with a Dart sealed class 22 -
03 Decisions I made while building Terradart 3 OpenTofu as
the default execution engine Terraform license change OpenTofu as the default MPL 2.0 BSL 1.1 August 2023 OpenTofu (stays on MPL 2.0 The code stays public. Internal use works the same as before. → A fork of Terraform 1.5. Started under the Linux Foundation, joined CNCF in April 2025. You can't sell a product with Terraform inside Stays on MPL 2.0, with no limits on commercial use. that competes with the vendor's paid services. Its license is less likely to change because of one company Sometimes it runs on Terraform With --engine terraform, or if that environment was last applied with Terraform, it uses the Terraform on that machine. Same if PATH has terraform but no tofu. If none is found, it fetches OpenTofu and uses it Source: terradart help engines (terradart_cli 0.38.1 23 -
03 Decisions I made while building Terradart 4 CLI installable
with dart install BEFORE dart pub global activate JIT Just-In-Time) on the Dart VM $ dart pub global activate terradart_cli NOW → dart install (since Dart 3.10 AOT Ahead-Of-Time) native execution $ dart install terradart_cli ↓ Install it with your usual Dart setup AOT compilation means fast startup No extra language runtimes or dedicated managers. It becomes a native executable, so the terradart One dart command on your machine installs it command you run again and again starts fast * terradart_cli requires Dart 3.12 or later (sources: dart.dev/tools/dart-install, terradart_cli pubspec.yaml) dart.dev: dart pub global / Packaging and distributing Dart CLI tools 24 -
04 Summary I've built Terradart around its public interface 01
Why I built it 02 What I care about Full-stack Dart IaC Public interface design 03 4 decisions along the way Type, API, and CLI design Codebase and static checks • After UI, servers, and AI, write cloud infra in Dart too • Generated infra.g.dart connects it to the app type-safely • Leave internals to AI and focus → on designing the visible parts • Easy for AI to use, and easy for a person to check at the end → Sensitive<T> sealed class OpenTofu dart install In Terradart, I build a public interface that AI can work with and people can check at the end From the Flutter 3.50 release blog 20261111 flutter.dev/blog/whats-new-in-flutter-350 25