TerraformUtility
Index
Constructors
constructor
Parameters
options: { stateCheckInIntervalInMs?: number; terraformBinary?: string; terragruntBinary?: string; timeoutInMs?: number } = {}
Overrides for the binaries invoked, the per-command timeout, and the state check-in interval.
terragruntBinarydefaults toterragrunt.timeoutInMsdefaults to 60 minutes for the commands that only read -plan,output,show.applyanddestroyrun unbounded unless it is given: a timeout there turns a slow apply into one killed part way through a mutation, and how long a stack legitimately takes is a fact about that stack rather than something a default can know. What bounds them instead is the caller - a CI job's own timeout, or a person at a terminal.stateCheckInIntervalInMsis how often terraform state is checked into the state provider while a command runs, 10 seconds by default. Terraform rewrites it as each resource completes.optionalstateCheckInIntervalInMs: number
optionalterraformBinary: string
optionalterragruntBinary: string
optionaltimeoutInMs: number
Returns TerraformUtility
Methods
apply
Runs
terragrunt run --all -- applyover every generated module folder.This changes real infrastructure, and runs with
-auto-approve. Use TerraformUtility.findPlannedDestroys beforehand if a destroy needs confirming.Parameters
terragruntDir: string
The directory octo generated the module folders into.
Returns Promise<TerraformRawResult>
deleteDestroyedFolders
Deletes the folder of each module in
moduleIdswhose terraform state holds no resources, as a folder emptied from intent holds once its destroy applied. A folder still holding resources is kept.Parameters
terragruntDir: string
The directory octo generated the module folders into.
moduleIds: string[]
The modules whose folders may go, such as those a commit emptied.
Returns Promise<string[]>
The modules whose folders were deleted.
destroy
Runs
terragrunt run --all -- destroyover every generated module folder.This tears down real infrastructure, and runs with
-auto-approve.Parameters
terragruntDir: string
Returns Promise<TerraformRawResult>
findPlannedDestroys
Every address a set of plans may destroy, across all folders. A recreate (
create+delete) counts, since the old object is still destroyed, and so does an action octo does not know.Lets a caller refuse to apply until the destroys have been shown, which apply cannot do on its own because it runs with
-auto-approve.Parameters
plans: Map<string, TerraformPlan>
Returns { address: string; moduleId: string; tfActions: string[] }[]
listModuleFolders
Returns the immediate sub-directories of
terragruntDirthat look like generated module folders (they contain aterragrunt.hcl). Each folder name is the octomoduleId.Parameters
terragruntDir: string
Returns Promise<string[]>
setArgsOnce
To append extra CLI arguments to the next command only. Returns
this, so it chains.Parameters
args: string[]
Returns this
validate
Runs
terragrunt run --all -- validateover every generated module folder, checking the generated HCL is well-formed. Unrelated to Octo.validate, which compares plans against intent.Parameters
terragruntDir: string
Returns Promise<TerraformRawResult>
Octo's single interface to the terraform and terragrunt binaries.
Octo.generate writes module folders; this runs them, and turns their output back into the shapes the other modes expect -
plan(dir, { json: true })feeds Octo.validate, andoutput(dir, { json: true })feeds Octo.commit. Routing every invocation through one class is what keeps flags, timeouts, and event emission consistent.Resolve it from the Container so that a run's terraform events reach the same listeners as everything else.
Utilities/Terraform