@quadnix/octo-build
Index
CLI/apply
CLI/check-rules
CLI/commit
CLI/create-anchor
CLI/create-app
CLI/create-external-resource
CLI/create-model
CLI/create-module
CLI/create-overlay
CLI/create-terraform-resource
CLI/generate
CLI/get-response
CLI/lock
CLI/run-action
CLI/unlock
CLI/validate
CLI/apply
ApplyCommandArguments
optionalallowDestroy
One destroy to let through, as <folder>/<address>, the way a refused apply prints it. Repeat the flag for each;
the apply then lets exactly those through and still refuses any other.
optionalautoApprove
Skips the destroy check and lets every destroy through, false by default. Also written --auto-approve.
optionallockId
The app lock ID octo lock printed. By default, the lock this app holds when it was taken in this state
directory.
optionalterraformBinary
The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own
choice by default.
optionalterragruntBinary
The Terragrunt binary to run, terragrunt by default.
terragruntDir
The generated directory to apply, .octo-tf by default.
optionaltimeoutInMs
A time limit for the apply, in milliseconds. None by default, since a limit that fires part way through leaves infrastructure half changed; the plans it runs first stop after 60 minutes unless this is given.
constapplyCommand
octo apply, step 3 of a run and the only command that changes live infrastructure. Run it after generate and
validate, holding the app lock octo lock took; it runs Terragrunt over the generated folders, which applies them
in the order their dependencies need, and never stops to ask for a yes. It does not release the lock, because the
apply is the middle of a run and commit is the end of it.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, and loads its modules
only to check every account's credentials have not ended; it reads no model or resource state.
Terraform's own state is checked out of the definition's state provider and back into it around the apply. It
verifies the lock before planning, so a run without it fails having done nothing. Applying a folder holding an
external resource runs octo run-action and octo get-response for it, and apply puts the octo binary on the
PATH for that.
Before applying, it plans every folder, and refuses when a folder cannot be planned or the plan would destroy
anything --allowDestroy does not name, unless --autoApprove is passed. The refusal lists each destroy on stderr,
marking one that loses the data it holds, a table or a bucket, with - the data it holds is lost with it, and ends
with one --allowDestroy '<folder>/<address>' per destroy, ready to paste.
Nothing goes to stdout; Terraform's progress reaches stderr through the definition's listeners. An apply that
fails part way prints the octo commit --partial that records what it did build, with this run's directory and
lock ID already in it; one that fails before applying anything does not, because there is nothing to record.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<ApplyCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<ApplyCommandArguments>
Returns Promise<void>
CLI/check-rules
constcheckRulesCommand
octo check-rules checks the rules file against the graph generate would write, writing nothing, and prints
what each rule found as JSON on stdout. Run it while writing or changing a rule, to see what the rule selects and
which exceptions are stale or name nothing; it takes no flags and needs no lock.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, and the rules file its
rules key names, else rules.yaml beside it. A rule that does not hold does not fail it; a missing rules file, or
a rule that cannot load or be evaluated, such as one reading a misspelled nested field, does.
Writing Rules covers the rules file.
Type declaration
command: string
describe: string
handler: () => Promise<void>
Returns Promise<void>
CLI/commit
CommitCommandArguments
The flags of octo commit.
optionallockId
The app lock ID octo lock printed, released when the commit succeeds. By default, the lock this app holds when
it was taken in this state directory.
optionalpartial
Records what did apply, after an apply that failed, false by default. It commits only the folders whose plan is
now empty, and within those every resource whose outputs all resolved; every other resource, and every resource
standing on one, keeps what the last commit recorded of it, or stays out of Octo's state if it was never
committed, and comes back as a warning naming what was skipped.
optionalterraformBinary
The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own
choice by default.
optionalterragruntBinary
The Terragrunt binary to run, terragrunt by default.
terragruntDir
The generated directory, after an apply, .octo-tf by default.
optionaltimeoutInMs
A time limit for each Terragrunt command, in milliseconds, 60 minutes by default.
constcommitCommand
octo commit, step 4 of a run and the end of it: it records what the apply produced, the IDs, ARNs and endpoints
only the cloud could know, into Octo's state, and releases the app lock. Run it after every apply; a skipped
commit leaves Octo believing none of it exists. It reads the definition file, octo.yaml or the file
OCTO_DEFINITION_FILE_PATH names, and needs credentials that have not ended.
It plans every folder, the same plan validate runs, then reads every folder's Terraform outputs. It records all
or nothing: a folder whose plan still holds changes, which would record a change that never reached the cloud, or
a missing or null output, fails it before any state is written. A commit that fails keeps the lock: fix what it
reported and run it again. After an apply that failed part way, --partial records the part that did apply.
Nothing goes to stdout; the commit report and its warnings go to stderr. It deletes each emptied folder whose destroy it committed, naming it on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CommitCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CommitCommandArguments>
Returns Promise<void>
CLI/create-anchor
CreateAnchorCommandArguments
The flags of octo create-anchor.
family
The directory under src/anchors/ to group the anchor in. Required.
name
The anchor's name, in kebab-case. Required; alias -n.
package
The package name of the library the anchor belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
type
The type of model the anchor attaches to: account, app, deployment, environment, execution, filesystem,
image, pipeline, region, server, service or subnet, or overlay. Required; alias -t.
constcreateAnchorCommand
octo create-anchor writes an anchor and its schema under src/anchors/<family>/, and imports it from
src/index.ts so its decorators register it. Run it when a model or overlay needs an anchor. It reads no
definition file.
It refuses a name that is not kebab-case, a package name that is not valid, and an anchor of that name already in the family, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateAnchorCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateAnchorCommandArguments>
Returns Promise<void>
CLI/create-app
CreateAppCommandArguments
The flags of octo create-app.
name
The app's name, and the name of the directory created for it. Required; alias -n.
path
The directory to create the app's directory in, . by default; alias -p.
constcreateAppCommand
octo create-app creates a project in a new directory named for the app, and runs npm install in it. The project
holds a package.json, its TypeScript and lint configs, and an octo.yaml with one account and one region, which
you extend with the modules your app needs. Run it once, through npx @quadnix/octo-build, to start a project; it
reads no definition file and needs no credentials. Project Structure
covers what it writes.
It refuses a directory that already holds files, prints its progress and Successfully created app! on stderr, and
exits non-zero on a failure. Nothing goes to stdout.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateAppCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateAppCommandArguments>
Returns Promise<void>
CLI/create-external-resource
CreateExternalResourceCommandArguments
The flags of octo create-external-resource.
name
The resource's name, in kebab-case. Required; alias -n.
package
The package name of the library the resource belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
constcreateExternalResourceCommand
octo create-external-resource writes a resource whose lifecycle runs outside Terraform, with its schema and its
add, update and delete actions, under src/resources/<name>/, and imports it from src/index.ts so its decorators
register it. Run it when a module needs something Terraform cannot create; for one it can, run
create-terraform-resource. It reads no definition file.
It refuses a name that is not kebab-case, a package name that is not valid, and a directory that already holds files, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateExternalResourceCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateExternalResourceCommandArguments>
Returns Promise<void>
CLI/create-model
CreateModelCommandArguments
The flags of octo create-model.
name
The name of the module the model belongs to, in kebab-case. Required; alias -n.
package
The package name of the library the model belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
type
The base model the model extends: account, app, deployment, environment, execution, filesystem,
image, pipeline, region, server, service or subnet. Required; alias -t.
constcreateModelCommand
octo create-model writes a model, its schema and its add action under
src/modules/<type>/<name>/models/<type>/, inside an existing module, and imports it from src/index.ts so its
decorators register it. Run it after create-module, when the module needs a model of its own. It reads no
definition file.
It refuses a name that is not kebab-case, a package name that is not valid, and a directory that already holds files, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateModelCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateModelCommandArguments>
Returns Promise<void>
CLI/create-module
CreateModuleCommandArguments
The flags of octo create-module.
name
The module's name, in kebab-case, such as checkout-server. Required; alias -n.
package
The package name of the library the module belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
type
The type of model the module is for: account, app, deployment, environment, execution, filesystem,
image, pipeline, region, server, service or subnet. Required; alias -t.
constcreateModuleCommand
octo create-module writes a module and its input schema under src/modules/<type>/<name>/, with the docblocks
Documenting a Module teaches left as Fix me placeholders, and
exports both from src/index.ts, so the definition file can name the module and an agent can read its inputs. Run
it in a project to start a module of your own; the model and its action are a separate command, create-model. It
reads no definition file.
It refuses a name that is not kebab-case, a package name that is not valid, and a directory that already holds files, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateModuleCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateModuleCommandArguments>
Returns Promise<void>
CLI/create-overlay
CreateOverlayCommandArguments
The flags of octo create-overlay.
name
The name of the module the overlay is written inside, in kebab-case. Required; alias -n.
overlay
The overlay's own name, in kebab-case. Required.
package
The package name of the library the overlay belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
type
The type of model the overlay is for: account, app, deployment, environment, execution, filesystem,
image, pipeline, region, server, service or subnet. Required; alias -t.
constcreateOverlayCommand
octo create-overlay writes an overlay, its schema and its add action under
src/modules/<type>/<name>/overlays/<name>-<overlay>/, inside an existing module, and imports it from
src/index.ts so its decorators register it. Run it when a module needs an overlay. It reads no definition file.
It refuses a module or overlay name that is not kebab-case, a package name that is not valid, and a directory that already holds files, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateOverlayCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateOverlayCommandArguments>
Returns Promise<void>
CLI/create-terraform-resource
CreateTerraformResourceCommandArguments
The flags of octo create-terraform-resource.
name
The resource's name, in kebab-case. Required; alias -n.
package
The package name of the library the resource belongs to, such as @shop. Required.
path
The project's root directory, . by default; alias -p.
constcreateTerraformResourceCommand
octo create-terraform-resource writes a resource whose lifecycle Terraform manages, with its schema, under
src/resources/<name>/, and imports it from src/index.ts so its decorators register it. Run it when a module
needs a resource Terraform can create. It reads no definition file.
It refuses a name that is not kebab-case, a package name that is not valid, and a directory that already holds files, and prints its progress and next steps on stderr.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<CreateTerraformResourceCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<CreateTerraformResourceCommandArguments>
Returns Promise<void>
CLI/generate
GenerateCommandArguments
The flags of octo generate.
outputDir
The directory to write the module folders into, .octo-tf by default; alias -o. Folders are overwritten in
place, never wiped, and a module deleted from intent leaves an emptied folder, so a later apply destroys its
resources.
constgenerateCommand
octo generate, step 1 of a run: it writes the Terragrunt module folders for the infrastructure the definition
file describes, and saves the model state. Run it first, after every change to the definition file or to a module;
it needs no lock and no credentials, and changes nothing in the cloud.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names. With a rules file, it
first checks the graph against it, and refuses a graph a rule does not hold for before writing anything. With
RemoteStateProvider, it first brings the state directory up to the newest state a finished run left in the
backend. Writing Rules covers rules, and
State Providers the remote state.
Nothing goes to stdout; what the listeners report goes to stderr, and a successful generate prints nothing else.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<GenerateCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<GenerateCommandArguments>
Returns Promise<void>
CLI/get-response
GetResponseCommandArguments
The flags of octo get-response.
resourceId
The ID of the resource whose response to print. Required.
constgetResponseCommand
octo get-response prints one resource's recorded response as JSON on stdout, and nothing else there. Terraform
runs it as a data "external" for an external resource, on every plan and every apply of the folder that resource
sits in; it is not a step you run yourself.
Create an External Resource covers external resources.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, for its state provider,
and Octo state and nothing else: no modules are composed and nothing is called, which is what makes it safe during
a plan. The response comes from what octo run-action recorded while the commit has not folded it in yet, and
from the committed resource graph after that. A resource that has neither is an error, and the plan or apply that
asked for it fails with that error.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<GetResponseCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<GetResponseCommandArguments>
Returns Promise<void>
CLI/lock
LockCommandArguments
The flags of octo lock.
optionallockId
Resumes the run holding this lock ID instead of taking a new lock. Stop that run's process first: its lock is still good, so a process that wakes up keeps writing into the same state.
constlockCommand
octo lock takes the app lock and prints its ID. Octo's state has one writer at a time, and the lock enforces it:
apply and commit both require it, while generate and validate write no shared state and need none. Run it
after validate and before apply; the commit that ends the run releases it.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, for its state provider.
The lock ID is the only thing on stdout, so a shell can capture it: LOCK_ID=$(octo lock); everything else goes
to stderr.
It fails when a lock is already held, naming the ID that holds it, before anything reads state or plans, so a
second runner stops at once. With RemoteStateProvider it also fails when another run finished after this
generate, so there generate comes first. It also fails while the state directory holds journal files a
released lock could not archive, naming them.
A lock never times out. A run that died is
finished rather than released: stop its process if it is still there, resume it with --lockId and the ID the
error named, then generate, apply and commit as usual. With a remote state provider, the run can be resumed from
any machine, by the account that took the lock or by an organization administrator, and resuming reads everything
the dead run had written. Recovering a Failed Run covers
what to check before the apply.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<LockCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<LockCommandArguments>
Returns Promise<void>
CLI/run-action
RunActionCommandArguments
The flags of octo run-action.
optionalinput
A parent's response value, as <parentResourceId>.<responseKey>=<value>. Repeat the flag for each; none by
default.
resourceId
The ID of the resource whose action to run. Required.
construnActionCommand
octo run-action runs one resource action for an external resource and prints the action's JSON result on
stdout, and nothing else there. Terraform runs it mid-apply through a generated provisioner; it is not a step you
run yourself.
Create an External Resource covers external resources.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, and composes its modules.
Octo's own listeners write to stderr for this command. What the action produced is recorded against the resource as
soon as it succeeds, and octo commit folds that record into the resource graph and clears it, so running it
twice for the same change does the work once.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<RunActionCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<RunActionCommandArguments>
Returns Promise<void>
CLI/unlock
UnlockCommandArguments
The flags of octo unlock.
lockId
The lock ID to release, as octo lock printed it. Required.
constunlockCommand
octo unlock finishes a run as it stands and releases its app lock. A successful commit releases its own lock,
so run this for a run that will not reach one: a run that never applied, or one somebody finished by hand.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, for its state provider.
Like commit, it seals the run into archives/<commitId>/: a copy of the state, and the journal moved beside it.
With a remote state provider, unlocking makes what the run wrote the newest state, which the next generate plans
against. Nothing goes to stdout; it says on stderr whether the app was unlocked or already was.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<UnlockCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<UnlockCommandArguments>
Returns Promise<void>
CLI/validate
ValidateCommandArguments
The flags of octo validate.
optionalterraformBinary
The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own
choice by default.
optionalterragruntBinary
The Terragrunt binary to run, terragrunt by default.
terragruntDir
The generated directory to plan, .octo-tf by default.
optionaltimeoutInMs
A time limit for each Terragrunt command, in milliseconds, 60 minutes by default.
constvalidateCommand
octo validate, step 2 of a run: it plans every generated folder with Terraform and reports the plans against
Octo's own diff, separating what changes because of the intent from drift nothing in the intent explains. Run it
after generate and before apply, to read what an apply would do; it needs no lock and creates nothing.
It reads the definition file, octo.yaml or the file OCTO_DEFINITION_FILE_PATH names, and needs credentials
that have not ended. Planning a folder holding an external resource runs octo get-response for it, which
reads Octo state and calls nothing; validate puts the octo binary on the PATH for that.
Nothing goes to stdout; the report goes to stderr through the definition's listeners. It exits non-zero only when a folder could not be planned: drift and destructive changes are findings, not failures. Reading a Validate Report covers what a report contains.
Type declaration
builder: (yargs: Argv) => Argv
Parameters
yargs: Argv
Returns Argv
command: string
describe: string
handler: (argv: ArgumentsCamelCase<ValidateCommandArguments>) => Promise<void>
Parameters
argv: ArgumentsCamelCase<ValidateCommandArguments>
Returns Promise<void>
The flags of
octo apply.CLI/apply