Logo

Autoschematic

GitHub
Cluster Login

Creating a Repo

At its core, Autoschematic uses Git as part of its state model. This means that everything you do with Autoschematic will take place within a Git repository. You'll probably want to create a dedicated repository for each Autoschematic project.

All the infrastructure that runs this site is provisioned with Autoschematic! Check it out on GitHub.

mkdir example-autoschematic
cd example-autoschematic
git init
autoschematic init

You should see a file, autoschematic.ron, created in the root of your new repo. This is the main Autoschematic configuration file.

A real-world autoschematic.ron file might look something like this. We've added some explanatory comments.

// The main config struct (RON is strongly typed, like Rust!)
AutoschematicConfig(
    prefixes: {
        // A single prefix called "main"...
        "main": Prefix(
            connectors: [
                // ...with a single connector, the "snowflake" connector.
                Connector(
                    shortname: "github",
                    // This connector exists as a binary crate on crates.io. 
                    // Note: the upcoming "connector catalogue" will soon obviate the need to add this spec.
                    spec: Cargo(
                        name: "autoschematic-connector-github",
                        version: "0.14.0"
                    ),
                    // Connector process will read its environment variables from .env
                    env_file: ".env",
                    env: {
                        // You can also set env vars directly. They take priority over those set in env_file.
                        "RUST_LOG": "info"
                    }
                )
            ]
        )
    }
)

In Autoschematic, resources and configuration files are divided into prefixes. You might use prefixes to separate different teams, offices, apps, accounts, or any other division you desire.

A prefix just corresponds to a folder at the root of your repo. Nested folders can be prefixes too. Think of them as namespaces for the resource files you manage inside a repo.

Here are some ways you could arrange your prefixes:

.
├── autoschematic.ron
└── offices/
    ├── london/
    ├── sanfrancisco/
    └── taipei/
AutoschematicConfig(
    prefixes: {
        "offices/london": Prefix(...),
        "offices/sanfrancisco": Prefix(...),
        "offices/taipei": Prefix(...),
    }
)

Or perhaps:

.
├── autoschematic.ron
└── team/
    ├── backend/
    ├── frontend/
    ├── network_admin/
    └── compliance/
AutoschematicConfig(
    prefixes: {
        "team/backend": Prefix(...),
        "team/frontend": Prefix(...),
        "team/network_admin": Prefix(...),
        "team/compliance": Prefix(...),
    }
)

You probably want to just start with one prefix, like this:

autoschematic.ron
AutoschematicConfig(
    prefixes: {
        "main": Prefix(
            connectors: [
            ]
        )
    }
)

There are only a few rules about prefixes that Autoschematic will enforce:

  • A prefix can never contain another prefix
  • A prefix must always exist under the root of the git repository, and can never use relative path components like .././
  • A prefix should always map to a single folder, and never to a symlink or similar

In the next section, we'll show a more advanced configuration example.

Next: Advanced Configuration