unit block is ubx’s fundamental primitive — it declares one cloud resource, gives it a name, and sets its attributes. Everything else in the language builds on top of this. Before you wire outputs into Helm charts, define multi-environment hierarchies, or author reusable components, you need to be comfortable with what a unit block looks like, how ubx validates it, and what it compiles to. That’s what this tutorial covers — and it’s deliberately small, because the goal is clarity, not completeness.
What you’ll learn
- The anatomy of a
.iacfile - The
unitblock — the fundamental building block of ubx - How
ubx validatetype-checks your infrastructure without touching the cloud
Why this matters
ubx validate never contacts the cloud — it reads your .iac files and the locally cached provider schema only. This means you can type-check infrastructure changes in CI without cloud credentials, and catch errors before they reach a real environment. It’s the first command you’ll run on every change.The source code
How it works
ubx parses the .iac file
The lexer tokenises the file and the parser builds an AST. Block type
unit, resource type aws_s3_bucket_v2, label assets, and attribute bucket are recorded.The type checker validates the schema
ubx looks up
aws_s3_bucket_v2 in the cached AWS provider schema (~/.ubx/schemas/aws.json). It confirms bucket is a valid string attribute. Unknown attributes produce a warning; missing required fields produce an error.What ubx generates
Common mistakes
Run it
What you learned
A
unit block declares a single cloud resource with a type and a labelubx validate type-checks your .iac files locally — no cloud credentials requiredProject config lives in
ubx.iac — name, runtime, backend, and stacks in one placeNext steps
Inputs and Outputs
Add typed variables and stack exports
unit block reference
Full unit block syntax and all supported meta-arguments
Full runnable example: github.com/ubiquex/ubx-examples/00-hello-world

