sincecutoff.com
← all changes

terraform console accepts a module scope

Introduced 2026-08-26 · score 0.95

HOW TO USE IT

When you need to evaluate an expression in a child module, run `terraform console` with `-scope` set to that module’s address. Add an index or key for a specific `count` or `for_each` instance.

printf '%s\n' '<expression>' | terraform console -scope='module.<name>'
printf '%s\n' '<expression>' | terraform console -scope='module.<name>[0]'
printf '%s\n' '<expression>' | terraform console -scope='module.<name>["<key>"]'

WHY THIS HELPS

Evaluate a Terraform expression in the context of a module or module instance.

BEFORE THIS CHANGE

The console evaluated expressions in the root module by default.

REQUIREMENTS AND LIMITATIONS

  • Version: 1.16.0
  • -scope=<module address>: Selects the module scope for expression evaluation; omit to use the root module. Use a module address, with an index for `count` instances or a key for `for_each` instances.
  • Prerequisite: Terraform v1.16.0 or later for this flag, introduced in v1.16.0.
  • Prerequisite: The selected child module must be present in the configuration; instance addresses use an index for `count` or a key for `for_each`.
  • The module scope is specified as a module address; the flag is optional.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card