Skip to main content

@quadnix/octo-build

Index

CLI/apply

ApplyCommandArguments

ApplyCommandArguments:

The flags of octo apply.

@group

CLI/apply

optionalallowDestroy

allowDestroy?: string[]

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

autoApprove?: boolean

Skips the destroy check and lets every destroy through, false by default. Also written --auto-approve.

optionallockId

lockId?: string

The app lock ID octo lock printed. By default, the lock this app holds when it was taken in this state directory.

optionalterraformBinary

terraformBinary?: string

The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own choice by default.

optionalterragruntBinary

terragruntBinary?: string

The Terragrunt binary to run, terragrunt by default.

terragruntDir

terragruntDir: string

The generated directory to apply, .octo-tf by default.

optionaltimeoutInMs

timeoutInMs?: number

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

applyCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<ApplyCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:apply
npm run octo:apply -- --allowDestroy 'receipts-module/aws_s3_bucket.bucket-shop-receipts'
@group

CLI/apply


Type declaration

  • builder: (yargs: Argv) => Argv
      • (yargs: Argv): Argv
      • Parameters

        • yargs: Argv

        Returns Argv

  • command: string
  • describe: string
  • handler: (argv: ArgumentsCamelCase<ApplyCommandArguments>) => Promise<void>

CLI/check-rules

constcheckRulesCommand

checkRulesCommand: { command: string; describe: string; handler: () => Promise<void> } = ...

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.

@example
npx octo check-rules
@group

CLI/check-rules


Type declaration

  • command: string
  • describe: string
  • handler: () => Promise<void>
      • (): Promise<void>
      • Returns Promise<void>

CLI/commit

CommitCommandArguments

CommitCommandArguments:

The flags of octo commit.

@group

CLI/commit

optionallockId

lockId?: string

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

partial?: boolean

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

terraformBinary?: string

The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own choice by default.

optionalterragruntBinary

terragruntBinary?: string

The Terragrunt binary to run, terragrunt by default.

terragruntDir

terragruntDir: string

The generated directory, after an apply, .octo-tf by default.

optionaltimeoutInMs

timeoutInMs?: number

A time limit for each Terragrunt command, in milliseconds, 60 minutes by default.

constcommitCommand

commitCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CommitCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:commit
npm run octo:commit -- --partial
@group

CLI/commit


Type declaration

  • builder: (yargs: Argv) => Argv
      • (yargs: Argv): Argv
      • Parameters

        • yargs: Argv

        Returns Argv

  • command: string
  • describe: string
  • handler: (argv: ArgumentsCamelCase<CommitCommandArguments>) => Promise<void>

CLI/create-anchor

CreateAnchorCommandArguments

CreateAnchorCommandArguments:

The flags of octo create-anchor.

@group

CLI/create-anchor

family

family: string

The directory under src/anchors/ to group the anchor in. Required.

name

name: string

The anchor's name, in kebab-case. Required; alias -n.

package

package: string

The package name of the library the anchor belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

type

type: string

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

createAnchorCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateAnchorCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/create-anchor


Type declaration

CLI/create-app

CreateAppCommandArguments

CreateAppCommandArguments:

The flags of octo create-app.

@group

CLI/create-app

name

name: string

The app's name, and the name of the directory created for it. Required; alias -n.

path

path: string

The directory to create the app's directory in, . by default; alias -p.

constcreateAppCommand

createAppCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateAppCommandArguments>) => Promise<void> } = ...

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.

@example
npx @quadnix/octo-build create-app -n shop
@group

CLI/create-app


Type declaration

CLI/create-external-resource

CreateExternalResourceCommandArguments

CreateExternalResourceCommandArguments:

The flags of octo create-external-resource.

@group

CLI/create-external-resource

name

name: string

The resource's name, in kebab-case. Required; alias -n.

package

package: string

The package name of the library the resource belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

constcreateExternalResourceCommand

createExternalResourceCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateExternalResourceCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/create-external-resource


Type declaration

CLI/create-model

CreateModelCommandArguments

CreateModelCommandArguments:

The flags of octo create-model.

@group

CLI/create-model

name

name: string

The name of the module the model belongs to, in kebab-case. Required; alias -n.

package

package: string

The package name of the library the model belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

type

type: string

The base model the model extends: account, app, deployment, environment, execution, filesystem, image, pipeline, region, server, service or subnet. Required; alias -t.

constcreateModelCommand

createModelCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateModelCommandArguments>) => Promise<void> } = ...

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.

@example
npx octo create-model -n checkout-server -t server --package @shop
@group

CLI/create-model


Type declaration

CLI/create-module

CreateModuleCommandArguments

CreateModuleCommandArguments:

The flags of octo create-module.

@group

CLI/create-module

name

name: string

The module's name, in kebab-case, such as checkout-server. Required; alias -n.

package

package: string

The package name of the library the module belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

type

type: string

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

createModuleCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateModuleCommandArguments>) => Promise<void> } = ...

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.

@example
npx octo create-module -n checkout-server -t server --package @shop
@group

CLI/create-module


Type declaration

CLI/create-overlay

CreateOverlayCommandArguments

CreateOverlayCommandArguments:

The flags of octo create-overlay.

@group

CLI/create-overlay

name

name: string

The name of the module the overlay is written inside, in kebab-case. Required; alias -n.

overlay

overlay: string

The overlay's own name, in kebab-case. Required.

package

package: string

The package name of the library the overlay belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

type

type: string

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

createOverlayCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateOverlayCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/create-overlay


Type declaration

CLI/create-terraform-resource

CreateTerraformResourceCommandArguments

CreateTerraformResourceCommandArguments:

The flags of octo create-terraform-resource.

@group

CLI/create-terraform-resource

name

name: string

The resource's name, in kebab-case. Required; alias -n.

package

package: string

The package name of the library the resource belongs to, such as @shop. Required.

path

path: string

The project's root directory, . by default; alias -p.

constcreateTerraformResourceCommand

createTerraformResourceCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<CreateTerraformResourceCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/create-terraform-resource


Type declaration

CLI/generate

GenerateCommandArguments

GenerateCommandArguments:

The flags of octo generate.

@group

CLI/generate

outputDir

outputDir: string

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

generateCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<GenerateCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:generate
@group

CLI/generate


Type declaration

CLI/get-response

GetResponseCommandArguments

GetResponseCommandArguments:

The flags of octo get-response.

@group

CLI/get-response

resourceId

resourceId: string

The ID of the resource whose response to print. Required.

constgetResponseCommand

getResponseCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<GetResponseCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/get-response


Type declaration

CLI/lock

LockCommandArguments

LockCommandArguments:

The flags of octo lock.

@group

CLI/lock

optionallockId

lockId?: string

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

lockCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<LockCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:lock
npm run octo:lock -- --lockId "$HELD_LOCK_ID"
@group

CLI/lock


Type declaration

  • builder: (yargs: Argv) => Argv
      • (yargs: Argv): Argv
      • Parameters

        • yargs: Argv

        Returns Argv

  • command: string
  • describe: string
  • handler: (argv: ArgumentsCamelCase<LockCommandArguments>) => Promise<void>

CLI/run-action

RunActionCommandArguments

RunActionCommandArguments:

The flags of octo run-action.

@group

CLI/run-action

optionalinput

input?: string[]

A parent's response value, as <parentResourceId>.<responseKey>=<value>. Repeat the flag for each; none by default.

resourceId

resourceId: string

The ID of the resource whose action to run. Required.

construnActionCommand

runActionCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<RunActionCommandArguments>) => Promise<void> } = ...

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.

@group

CLI/run-action


Type declaration

CLI/unlock

UnlockCommandArguments

UnlockCommandArguments:

The flags of octo unlock.

@group

CLI/unlock

lockId

lockId: string

The lock ID to release, as octo lock printed it. Required.

constunlockCommand

unlockCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<UnlockCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:unlock -- --lockId "$LOCK_ID"
@group

CLI/unlock


Type declaration

  • builder: (yargs: Argv) => Argv
      • (yargs: Argv): Argv
      • Parameters

        • yargs: Argv

        Returns Argv

  • command: string
  • describe: string
  • handler: (argv: ArgumentsCamelCase<UnlockCommandArguments>) => Promise<void>

CLI/validate

ValidateCommandArguments

ValidateCommandArguments:

The flags of octo validate.

@group

CLI/validate

optionalterraformBinary

terraformBinary?: string

The Terraform or OpenTofu binary Terragrunt invokes, such as tofu, set as TG_TF_PATH. Terragrunt's own choice by default.

optionalterragruntBinary

terragruntBinary?: string

The Terragrunt binary to run, terragrunt by default.

terragruntDir

terragruntDir: string

The generated directory to plan, .octo-tf by default.

optionaltimeoutInMs

timeoutInMs?: number

A time limit for each Terragrunt command, in milliseconds, 60 minutes by default.

constvalidateCommand

validateCommand: { builder: (yargs: Argv) => Argv; command: string; describe: string; handler: (argv: ArgumentsCamelCase<ValidateCommandArguments>) => Promise<void> } = ...

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.

@example
npm run octo:validate
@group

CLI/validate


Type declaration