Documentation
¶
Overview ¶
Package instances resolves Terraform count and for_each expressions into bounded instance plans, without evaluating block bodies or charging budgets.
Index ¶
Constants ¶
const ( // KindCount and KindForEach name the meta-argument a block expands by. KindCount = "count" KindForEach = "for_each" )
const MaxPerBlock = 50
MaxPerBlock caps the instances expanded from one count or for_each block.
Variables ¶
This section is empty.
Functions ¶
func Attributes ¶
func Attributes(body *hclsyntax.Body) (count, forEach hcl.Expression)
Attributes picks the count and for_each expressions of an HCL body.
func ForEachCollection ¶
ForEachCollection reports whether v is a known, non-null map, object or set with known length. Keys are validated during expansion; values may be unknown.
Types ¶
type Plan ¶
type Plan struct {
// Kind is empty for a block without count or for_each.
Kind string
// Unresolved means the expression failed or its instance keys are unknown
// or invalid. No concrete Items are returned in this case.
Unresolved bool
// Requested is the full instance count before the per-block cap, when known.
Requested int
Items []Item
// ForEachKeys retains all keys only for truncated collections small enough
// to preserve their output shape. Otherwise it is nil.
ForEachKeys []cty.Value
}
Plan describes an expansion independently of the caller's evaluation context.
func Resolve ¶
func Resolve(count, forEach hcl.Expression, ctx *hcl.EvalContext, maxShape int) Plan
Resolve expands the supplied expressions (nil when absent). Count takes precedence if both are present, matching the module evaluator's fallback for invalid configurations. maxShape bounds retention of truncated for_each keys; callers may use these keys to pad unevaluated outputs with unknown values. Values retain their cty marks, including marks on each.value.