Skip to main content
ubx fmt formats .iac files in place using the canonical ubx style. Similar to terraform fmt or gofmt.

Usage

ubx fmt [path] [flags]

Examples

ubx fmt                   # format all .iac files in current directory
ubx fmt main.iac          # format specific file
ubx fmt ./stacks/         # format all files in directory
ubx fmt --dry-run         # show what would change without writing
ubx fmt --check           # exit 1 if any files need formatting (CI mode)

Flags

FlagDescription
--dry-runShow diff without writing files
--checkExit 1 if any files need formatting

Formatting Rules

  • Consistent 2-space indentation
  • Aligned = signs within a block
  • Single blank line between blocks
  • Sorted attribute keys (alphabetically within each block)
  • Canonical quoting (double quotes for strings)

Example

Before:
unit "aws_s3_bucket_v2" "assets" {
    bucket="my-assets"
  force_destroy=true
  tags={env="prod", team="platform"}
}
After ubx fmt:
unit "aws_s3_bucket_v2" "assets" {
  bucket        = "my-assets"
  force_destroy = true
  tags = {
    env  = "prod"
    team = "platform"
  }
}

CI Usage

# Fail CI if files aren't formatted
ubx fmt --check || exit 1

.ubxignore Respected

Files excluded via .ubxignore are not formatted.