TerraformModuleScope
Index
Properties
readonlymoduleId
The ID of the octo module this folder was generated for.
Methods
addOctoTerraformExternalResource
Wraps an octo resource whose lifecycle runs outside Terraform (e.g. a script or SDK call). Generates a
null_resource+data "external"pair that callsocto run-actionat apply time and exposes the result as outputs.Type parameters
- T: UnknownResource
Parameters
octoResource: T
Returns OctoTerraformResourceScope<ResourceSchema<T>[response]>
addOctoTerraformResource
Registers an octo resource as a native Terraform resource. Returns an OctoTerraformResourceScope on which you call
addTerraformResource()to emit HCL blocks andoutput()to declare what other resources can reference.- Pass
options.explicitParentsfor dependencies that aren't captured by attribute references alone. - Pass
options.providerto pin the resource to a specific account/region provider.
Type parameters
- T: UnknownResource
Parameters
octoResource: T
optionaloptions: { explicitParents?: (UnknownResource | MatchingResource<BaseResourceSchema>)[]; provider?: TerraformProviderContext }
optionalexplicitParents: (UnknownResource | MatchingResource<BaseResourceSchema>)[]
optionalprovider: TerraformProviderContext
Returns OctoTerraformResourceScope<ResourceSchema<T>[response]>
- Pass
addTerraformData
Emits a
data "<type>" "<name>"block. Use for read-only data sources that look up existing infrastructure (e.g.aws_ami,aws_caller_identity).Parameters
type: string
name: string
optionalspec: Record<string, unknown>
Returns TerraformData
getProviderAliasRef
Returns the
<providerType>.<alias>expression for a registered provider. Pass the result as theproviderattribute when a resource must target a specific account/region different from the module's default.Parameters
accountId: string
optionalregionId: string
Returns HclExpression
getRef
Returns a reference to another resource's output that resolves correctly at render time: an inline TF expression when the producer is in the same module, or a
var.*wired through terragrunt when it is in a different module.Type parameters
- T: UnknownResource
Parameters
resource: T
key: keyof ResourceSchema<T>[response] & string
Returns HclExpression
interpolate
Joins text and references into one quoted terraform string, for when a value is another resource's output with text of this resource's own around it. Each reference resolves as TerraformModuleScope.getRef does, so a producer in another folder is still wired in.
Parameters
rest...parts: (string | HclExpression)[]
Returns HclExpression
jsonencode
Wraps a value in a
jsonencode(...)call.Parameters
subject: object | unknown[]
Returns HclExpression
localPath
Returns the HCL for a file on the developer's disk, as a quoted string ready to pass to TerraformModuleScope.raw or to a terraform function such as
filemd5.The path renders relative to the octo project root and is joined to
var.OCTO_PROJECT_ROOTat plan time, so the generated folder holds the same text whichever machine wrote it. Terragrunt runs terraform from a copy of the folder, so a plain relative path would not resolve.Parameters
filePath: string
Returns string
mapAttr
Use
mapAttr()when the provider schema defines a map/object attribute (key = { }). Use a plain JS object in the resource spec when the schema expects a block (key { }). The distinction matters: blocks have no=. Check the provider docs for each argument.Parameters
value: Record<string, unknown>
Returns HclExpression
raw
Emits a value verbatim as a terraform expression (no quoting).
Parameters
value: unknown
Returns HclExpression
type
Returns a terraform
type(...)expression for use invariabledeclarations.Parameters
schema: unknown
Returns HclExpression
variable
Declares a user-supplied input variable for this module. Use when a value must be provided at apply time rather than derived from another resource's output.
Parameters
name: string
typeExpression: unknown
options: { default: TerraformLiteralType; sensitive: boolean }
default: TerraformLiteralType
sensitive: boolean
Returns TerraformVariable
The terraform module folder a resource writes itself into.
Octo hands one to ATerraformResource.toHCL, scoped to the folder that resource belongs to. It is a small HCL builder: register the octo resource, emit blocks on the scope it returns, and reference other resources through TerraformModuleScope.getRef rather than by writing addresses by hand - only
getRefknows whether the producer lands in this folder or another one.Resources
ATerraformResource for where this is used.