Help us shape the future of Go! Take the 2026 Go Developer Survey

dynamicblock

package
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package dynamicblock expands Terraform dynamic blocks into the nested blocks they generate.

Index

Constants

View Source
const (

	// MaxExpansion caps the blocks one dynamic block generates; a larger
	// for_each is kept as written rather than expanded in part.
	MaxExpansion = 256
	// MaxGeneratedPerResource caps the blocks the dynamic blocks under one resource
	// (or other top-level block) generate in total, nested ones included, so
	// nesting cannot multiply the per-block cap.
	MaxGeneratedPerResource = 1024
)

Variables

This section is empty.

Functions

func Content

func Content(b *hclsyntax.Block) *hclsyntax.Body

Content returns the body every generated block is evaluated from.

func GeneratedType

func GeneratedType(b *hclsyntax.Block) string

GeneratedType is the type of the blocks b generates.

func Is

func Is(b *hclsyntax.Block) bool

Is reports whether b is a dynamic block.

func IteratorName

func IteratorName(b *hclsyntax.Block) string

IteratorName is the variable the content reads the current element through.

func Labels

func Labels(b *hclsyntax.Block, ctx *hcl.EvalContext) (labels []string, ok bool)

Labels evaluates the labels of a generated block under ctx, which binds its iterator. ok is false when the labels attribute does not resolve to strings, which is different from a block that has no labels.

Types

type Expansion

type Expansion struct {
	// Iterators holds the iterator value of every block generated; empty unless Resolved.
	Iterators []cty.Value
	// Requested is how many blocks for_each asks for, whether or not they were
	// expanded; zero when for_each does not resolve.
	Requested int
	// Resolved is false when for_each cannot be resolved, or asks for more than
	// MaxExpansion blocks: how many blocks the dynamic block generates, possibly
	// none, is then unknown, and callers keep it as written so rules can tell a
	// block that may be absent from one that is present, and no generated block
	// is silently dropped.
	Resolved bool
	// OverCap is set when for_each resolves but asks for more than MaxExpansion.
	OverCap bool
}

Expansion is what a dynamic block's for_each yields under an evaluation context.

func Expand

func Expand(b *hclsyntax.Block, ctx *hcl.EvalContext) Expansion

Expand evaluates the for_each of b under ctx.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL