Logo

Autoschematic

GitHub
Cluster Login

Scaffolding New Resources

To help with day-to-day creation of resourcecs, most connectors provide "skeleton" resource templates, and autoschematic create lets you choose one interactively and write it into the repo.

autoschematic create
Select prefix: main
Select connector: aws/iam
Select object: aws/iam/roles/[role_name].ron
role_name: minecraft-server-support
Writing main/aws/iam/roles/minecraft-server-support.ron

You pick a prefix, then a connector, then one of the skeleton paths that connector exposes. If the path contains placeholders like [role_name], autoschematic will prompt you for each value before it writes the file.

Connecting dependent resources

Autoschematic supports linked and dependent resources. Soon, it will even support discovering these links automatically. For example, an AWS route table role might link to an internet gateway's ID by reference, avoiding the need to paste this value directly:

RouteTable(
    routes: [
        Route(
            destination_cidr_block: "10.32.0.0/16",
            destination_ipv6_cidr_block: None,
            gateway_id: "local",
            instance_id: None,
            nat_gateway_id: None,
        ),
        Route(
            destination_cidr_block: "0.0.0.0/0",
            destination_ipv6_cidr_block: None,
            gateway_id: "out://aws/vpc/us-east-1/internet_gateways/autoschematic-ecs.ron[internet_gateway_id]",
            instance_id: None,
            nat_gateway_id: None,
        ),
    ],
    tags: {},
)

The out://... syntax is how connectors express dependencies between resources. Autoschematic will resolve those dependencies during plan and apply and make sure operations are ordered correctly.

In this case,

"out://aws/vpc/us-east-1/internet_gateways/autoschematic-ecs.ron[internet_gateway_id]"

references the output internet_gateway_id in the file aws/vpc/us-east-1/internet_gateways/autoschematic-ecs.ron within the same prefix as the source file.

Next: Resolving State Drift