A disciplined, compiled, and statically-typed approach to Infrastructure as Code. https://maiwald.work
Find a file
Markus Maiwald 6643931993
Some checks failed
Tectonic CI / build (push) Has been cancelled
feat(phase3): Complete Phase 3 - provider blocks, variables, and outputs
Provider Detection:
- Auto-detect required providers from resource type prefixes
- Generate terraform { required_providers { } } block in HCL output
- Support for GCP, Hetzner, AWS, Kubernetes, Cloudflare providers

Variables:
- Add Variable type with name, type, description, default, sensitive
- Support types: string, number, bool, list, map, any
- Parse variable blocks from KDL
- Generate HCL variable blocks

Outputs:
- Add Output type with name, value, description, sensitive
- Parse output blocks from KDL
- Generate HCL output blocks

Infrastructure:
- Update types.nim with Variable, Output, VariableType
- Update kdl_parser.nim with variable/output parsing
- Update tofu.nim with HCL generation
- Update json_io.nim for JSON serialization
- Update backend.nim to carry variables/outputs in config
- Add test_variables.nim with 18 tests
- Add examples/variables.tect demo file
- Update README.md documentation

Phase 3 complete: 75 total tests passing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-14 11:58:09 +01:00
.gitea/workflows Phase 0: Add CI pipeline and core types. 2025-08-13 12:34:06 +02:00
.vscode housekeeping, cleanup some files 2025-09-08 00:03:42 +02:00
examples feat(phase3): Complete Phase 3 - provider blocks, variables, and outputs 2026-01-14 11:58:09 +01:00
schemas feat(milestone): Multi-backend infrastructure compiler with AI integration 2026-01-13 23:41:12 +01:00
src feat(phase3): Complete Phase 3 - provider blocks, variables, and outputs 2026-01-14 11:58:09 +01:00
tests feat(phase3): Complete Phase 3 - provider blocks, variables, and outputs 2026-01-14 11:58:09 +01:00
.gitignore chore: add tests/ binaries to gitignore 2026-01-14 09:55:09 +01:00
.mcp.json feat(mcp): Add Claude Code MCP integration config 2026-01-14 03:10:07 +01:00
build.nim Test commit with GPG signing 2025-08-25 18:15:54 +02:00
LICENSE LICENCE: proper licencing with a strong copyleft 2025-09-08 00:20:11 +02:00
README.md feat(phase3): Complete Phase 3 - provider blocks, variables, and outputs 2026-01-14 11:58:09 +01:00
tectonic Test commit with GPG signing 2025-08-25 18:15:54 +02:00
tectonic.nimble chore: initial commit 2025-08-13 18:41:38 +02:00

Tectonic

CI/CD Status

A disciplined, compiled, and statically-typed approach to Infrastructure as Code.

Tectonic is a DSL and compiler, written in Nim, for infrastructure experts who demand a superior programming environment for defining, deploying, and managing cloud infrastructure. It transpiles a high-level, type-safe DSL into declarative, auditable configuration files for OpenTofu, Pulumi TypeScript, and Pulumi Python.

For engineers who find HCL/YAML too primitive and Python/TypeScript too loose for managing critical infrastructure.


Features

  • KDL-based DSL - Clean, human-readable .tect files using KDL syntax
  • Multi-backend output - Generate OpenTofu HCL, Pulumi TypeScript, or Pulumi Python
  • High-level abstractions - web_service, static_site, database, vpc_network expand into multiple resources
  • Dependency management - Automatic topological sorting and cycle detection
  • Type-safe properties - Strings, numbers, booleans, lists, maps, references, environment variables
  • Variables and Outputs - Input variables with defaults and typed output values
  • Auto provider detection - Automatically generates required_providers blocks from resource types
  • Multi-provider support - GCP, Hetzner Cloud, AWS, Kubernetes, Cloudflare

Quick Start

Prerequisites

Installation

git clone https://git.maiwald.work/markus/tectonic.git
cd tectonic
nimble install nimkdl
nim c -d:release -o:tectonic src/tectonic.nim

Usage

Create a .tect file:

// infrastructure.tect
tectonic "my-project" {
  resource "web_service" "api" {
    provider "gcp"
    zone "us-central1-a"
    machine_type "e2-medium"
    port 8080
    enable_lb #true
  }

  resource "gcs_bucket" "data" {
    location "EU"
    storage_class "STANDARD"
  }

  resource "gcp_instance" "worker" {
    machine_type "e2-small"
    zone "us-central1-b"
    depends_on "gcs_bucket.data"
  }
}

Compile to OpenTofu HCL:

tectonic compile infrastructure.tect --backend=tofu --out=./generated

Or generate for multiple backends:

tectonic compile infrastructure.tect --backend=tofu,pulumi-ts,pulumi-py --out=./generated

DSL Syntax

Resources

resource "resource_type" "name" {
  property_name "string value"
  numeric_prop 42
  bool_prop #true
  list_prop "item1" "item2" "item3"
  depends_on "other_resource.name"
}

High-Level Abstractions

Abstractions automatically expand into multiple low-level resources:

Abstraction Expands To
web_service compute instance + firewall + optional load balancer
static_site storage bucket + website config + IAM + optional CDN
database SQL instance + database + backup configuration
vpc_network network + subnets + firewall rules

Example:

resource "web_service" "api" {
  provider "gcp"
  zone "us-central1-a"
  enable_https #true
  enable_lb #true
}

Expands to 3 resources: gcp_instance.api, gcp_firewall.api-allow-80, gcp_load_balancer.api-lb

Environment Variables

Use ${VAR} syntax for environment variable substitution:

resource "hetzner_server" "web" {
  datacenter "${HETZNER_DC}"
  server_type "cx21"
}

Variables

Define input variables with type, description, default value, and sensitivity:

variable "environment" {
  type "string"
  description "Deployment environment"
  default "dev"
}

variable "instance_count" {
  type "number"
  default 3
}

variable "db_password" {
  type "string"
  description "Database password"
  sensitive #true
}

Supported types: string, number, bool, list, map, any

Outputs

Define output values to expose resource attributes:

output "instance_ip" {
  value "gcp_instance.app.network_interface.0.network_ip"
  description "The application server IP"
}

output "db_connection" {
  value "postgresql://user@${gcp_sql_instance.db.connection_name}/app"
  description "Database connection string"
  sensitive #true
}

CLI Reference

tectonic <command> [options]

Commands:
  compile <input>      Compile .tect file to infrastructure code
  validate <input>     Validate resources against schemas
  schema <type>        Show schema for a resource type
  list-resources       List all available resource types
  mcp-serve            Start MCP server for Claude Code integration
  help                 Show help message

Compile Options:
  --backend=<name>     Target: tofu, pulumi-ts, pulumi-py (default: tofu)
  --out=<dir>          Output directory (default: ./output)
  --format=json        Output as JSON instead of writing files

Project Structure

src/tectonic/
├── types.nim          # Core data types (Resource, Variable, Output, PropertyValue)
├── dsl.nim            # Nim DSL macros
├── kdl_parser.nim     # KDL file parser
├── abstractions.nim   # High-level infrastructure abstractions
├── providers.nim      # Provider registry and detection
├── depgraph.nim       # Dependency graph and cycle detection
├── backend.nim        # Backend abstraction layer
├── backends/
│   ├── tofu.nim       # OpenTofu HCL generator
│   ├── pulumi_ts.nim  # Pulumi TypeScript generator
│   └── pulumi_py.nim  # Pulumi Python generator
└── mcp/               # Claude Code MCP integration

Development

Running Tests

./tests/run_tests.sh

Building

# Debug build
nim c src/tectonic.nim

# Release build
nim c -d:release --mm:orc -o:tectonic src/tectonic.nim

Roadmap

  • Phase 1: Core DSL and OpenTofu backend
  • Phase 2: KDL parsing and high-level abstractions
  • Phase 3: Provider blocks, variables/outputs
  • Phase 4: Environment parameterization (dev/staging/prod)
  • Phase 5: Direct API provisioning

License

This project is licensed under the European Union Public Licence v. 1.2. See the LICENSE file for details.