* update the factories overview * update agent rules * update main GEMINI file * add preferred workflow to GEMINI file
1.4 KiB
1.4 KiB
trigger
| trigger |
|---|
| always_on |
Context-Based Interpolation
When designing factory patterns or datasets, you MUST leverage the context-based interpolation system.
A context object variable is used to hold maps of known, existing resource IDs (such as project_ids, folder_ids, networks, iam_principals).
Usage Pattern
-
Variables: Add a
contextvariable invariables.tf.variable "context" { description = "Context-specific interpolations." type = object({ project_ids = optional(map(string), {}) folder_ids = optional(map(string), {}) }) default = {} } -
Locals: Build
ctxandctx_plocal variables inmain.tfby flattening thevar.contextobject.locals { ctx = { for k, v in var.context : k => { for kk, vv in v : "${local.ctx_p}${k}:${kk}" => vv } } ctx_p = "$" } -
Lookups: Apply lookups inside resources.
project = lookup(local.ctx.project_ids, var.project_id, var.project_id) -
YAML Interpolation: In factory YAML files, use the
$prefix convention to reference the lookup map keys.# Instead of hardcoding the folder ID: parent: folders/1234567890 parent: $folder_ids:teams/team-a
This pattern makes YAML configuration files highly portable across installations and environments by substituting mnemonic keys for hardcoded values.