Skip to main content

Infra Lang

Write infrastructure once, compile it to Kubernetes, Compose, or GitHub Actions.

PyPI CI Docs License Python

Infra Lang is an Infrastructure-as-Code DSL for DevOps engineers, SREs, and platform teams. You describe your application — services, databases, queues, secrets, and pipelines — in one declarative .infra file, and Infra Lang compiles it to Kubernetes YAML, Docker Compose, Terraform HCL, or a GitHub Actions workflow. Instead of hand-writing and maintaining the same app in four different formats, you maintain one source of truth.

Quick demo

A single .infra file describes a service:

# app.infra
service api {
    image: "myapp/api:v1.0.0"
    replicas: 3
    port 8080
    health http("/health")
    resources {
        requests { cpu: 200m, memory: 256Mi }
        limits   { cpu: 1000m, memory: 512Mi }
    }
}

Compile it to Kubernetes:

infra compile app.infra --target kubernetes

Infra Lang produces the matching Deployment and Service:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: api
spec:
  replicas: 3
  selector:
    matchLabels:
      app.kubernetes.io/name: api
  template:
    spec:
      containers:
        - name: api
          image: myapp/api:v1.0.0
          ports:
            - containerPort: 8080
              name: port-0
          resources:
            requests: { cpu: 200m, memory: 256Mi }
            limits:   { cpu: 1000m, memory: 512Mi }
          readinessProbe:
            httpGet: { path: /health, port: 8080 }
---
apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app.kubernetes.io/name: api
  ports:
    - port: 8080
      targetPort: 8080

The same file compiles to Docker Compose with no rewriting:

infra compile app.infra --target compose

A pipeline block compiles to a GitHub Actions workflow:

pipeline ci {
    trigger { branches: ["main"] }
    stages {
        test: { runsOn: "ubuntu-latest" steps { t: { run: "pytest" } } }
    }
}
infra compile app.infra --target github

Features

  • 11 top-level resource types — service, database, cache, queue, storage, network, secret, config, pipeline, environment, cluster.
  • 5 compilation targets — Kubernetes (17 resource kinds), Helm charts, Docker Compose, Terraform HCL (AWS/GCP/Azure), GitHub Actions.
  • Compiler-grade validation — 30+ error codes with source locations and actionable hints; invalid configs fail before anything is emitted.
  • Built-in security linter (SEC001–SEC010) and reliability linter (REL001–REL014); Error-severity findings block compilation.
  • A language server — context-aware completion, hover docs, live diagnostics with links and related info, go-to-definition, find-references, workspace symbols, symbol rename, signature help, document highlight, semantic tokens, folding, formatting, and quick-fixes — all across every .infra file on disk.
  • A formatter, REPL, and diff engine — infra fmt, infra repl, and infra diff for reviewing changes.
  • Reusable pieces — template-string interpolation, import with cycle detection, extends inheritance, 25+ stdlib functions and a prelude of shared constants.

Try it in Codespaces

Click the button below to open this project in GitHub Codespaces:

Open in Codespaces

No local installation needed — full dev environment in about 2 minutes (Python 3.12, Docker-in-Docker, kubectl/helm, Ruff/Mypy extensions).

Installation

pip install infra-lang

With the language server (recommended for VS Code):

pip install 'infra-lang[lsp]'

Verify:

infra --version
infra --help

Note: For the latest development version, install from Git: pip install git+https://github.com/TuviDev/infra-lang.git

Requirements: Python 3.11+.

Getting started

Full documentation is hosted at TuviDev.github.io/infra-lang.

The fastest path is the 5-minute quickstart. In short:

  1. Write a .infra file (see the demo above).
  2. Validate it: infra validate app.infra
  3. Compile to a target: infra compile app.infra --target kubernetes
  4. Inspect the output in infra-out/, or preview with --dry-run.
  5. Iterate with infra fmt app.infra and infra diff app.infra app2.infra.

There is also a guided tutorial and commented examples.

Supported targets

Target Command What it generates
Kubernetes -t kubernetes Deployments, Services, Ingress, StatefulSets, PVCs, ConfigMaps, Secrets, CronJobs, HPA, PDBs, NetworkPolicies, ResourceQuotas, Namespaces, RBAC, TopologySpreadConstraints
Helm -t helm A complete chart: Chart.yaml, values.yaml, templates/, _helpers.tpl, .helmignore
Docker Compose -t compose docker-compose.yml, .env.example, Makefile
Terraform -t terraform main.tf, variables.tf, outputs.tf, providers.tf (AWS/GCP/Azure)
GitHub Actions -t github .github/workflows/*.yml, dependabot.yml

Not every resource type maps to every target — for example, pipeline compiles only to GitHub Actions, and cluster only to Terraform. See the support matrix for the full mapping.

Documentation

The documentation is hosted at TuviDev.github.io/infra-lang.

Doc What it covers
Quickstart 5-minute first run
Language spec Full DSL reference (blocks, fields, error codes)
Support matrix Which resources map to which targets
LSP / editor support VS Code extension and language server
Known limitations Honest boundaries of the project

Contributing

Contributions are welcome. See CONTRIBUTING.md for how to set up a dev environment, add a backend or a grammar rule, and the coding standards (ruff, mypy). Please read our Security policy before reporting a vulnerability.

License

Licensed under the MIT License.


Infra Lang is inspired by the ideas behind Terraform, Score, and Pulumi: declarative infrastructure that is easy to read and hard to get wrong.

Metadata

Release files for infra-lang 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infra-lang 0.2.0
File Size Uploaded
infra_lang-0.2.0.tar.gz 130.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for infra-lang 0.2.0
File Interpreter ABI Platform
infra_lang-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 290.6 kB

Release files / infra_lang-0.2.0.tar.gz

Download URL infra_lang-0.2.0.tar.gz
Size 130.9 kB
Tags Source
SHA-256 checksum
How to use checksums
10bfa35ee6bb87e0c9fc806dcb70efd68c6f211d5d053b25a03aa3b6f9bec0f2
BLAKE2b-256 checksum
How to use checksums
f3b138fa179b707b1710e65051de358af2890eeed95a3e63311fca2367b01cdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / infra_lang-0.2.0-py3-none-any.whl

Download URL infra_lang-0.2.0-py3-none-any.whl
Size 159.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bb123fb96e124ce38756c8c0bb07f131a1ee9aac880e4b1faf24d8cd35dd004d
BLAKE2b-256 checksum
How to use checksums
cc609eede9963193dd369bd570955a2d410e6eb4042f20c95da2b698e839b597
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

1.0.1

2 release files

1.0.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.6

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page