Skip to main content
Define your S2 infrastructure in a JSON spec file and apply it declaratively using the CLI. Resources that already exist are reconfigured to match the spec, and only the fields present in the spec are updated.

Spec file format

The spec is a JSON file with a top-level basins array. Each basin entry has a name, an optional config, and an optional streams array.

IDE setup

Add the $schema key to your spec file to point to the published schema hosted on GitHub to enable inline validation and autocomplete in your editor:
Or generate a local copy and reference it by path:
VS Code: configure schema associations in .vscode/settings.json so $schema is not needed in every file:
You can use any glob pattern in fileMatch to match your spec files by naming convention. IntelliJ / JetBrains IDEs: add a schema mapping in the IDE settings:
  1. Open Settings (Ctrl+Alt+S / ⌘,) → Languages & FrameworksSchemas and DTDsJSON Schema Mappings
  2. Click + to add a new mapping
  3. Give the mapping a name (e.g. S2 Spec)
  4. Set the schema to https://raw.githubusercontent.com/s2-streamstore/s2/main/cli/schema.json (or a local path)
  5. Set the Schema version to JSON Schema version 7
  6. Add file patterns to associate (e.g. *.s2spec.json)

Basin config fields

Stream config fields

Timestamping

Delete-on-empty

Set min_age to a humantime duration (e.g. "1day", "2h 30m") to enable automatic deletion of empty streams once they reach that age. The default of "0s" disables delete-on-empty.

Dry run

Preview what would change without making any mutations:
Output uses the following legend: Example output:
For the full list of CLI flags, see s2 apply.