|
Some checks failed
Tectonic CI / build (push) Has been cancelled
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>
|
||
|---|---|---|
| .gitea/workflows | ||
| .vscode | ||
| examples | ||
| schemas | ||
| src | ||
| tests | ||
| .gitignore | ||
| .mcp.json | ||
| build.nim | ||
| LICENSE | ||
| README.md | ||
| tectonic | ||
| tectonic.nimble | ||
Tectonic
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
.tectfiles using KDL syntax - Multi-backend output - Generate OpenTofu HCL, Pulumi TypeScript, or Pulumi Python
- High-level abstractions -
web_service,static_site,database,vpc_networkexpand 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_providersblocks 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.