Skip to content
Latchkey

Terragrunt "local ... is not defined" in CI

Terragrunt evaluated a local.X reference and found no such value in the module locals or the locals merged in from an included parent. The name is misspelled, missing, or lives in a parent that was not included.

What this error means

terragrunt fails with "Unsupported attribute" or "local.X is not defined" while parsing the config, before Terraform runs.

terragrunt
ERRO[0000] Error: Unsupported attribute
  on terragrunt.hcl line 8, in inputs:
   8:   region = local.aws_region
This object does not have an attribute named "aws_region".

Common causes

The local is not declared where it is used

The locals { } block in this file does not define the name, and no included parent contributes it.

The parent that defines the local was not included

The value lives in a parent config, but this module has no include (or does not read the parent locals), so the name is undefined here.

How to fix it

Declare the local or read it from the parent

  1. Confirm which locals block should define the value.
  2. Add it to this module locals, or read the parent config that defines it.
  3. Re-run so the reference resolves.
terragrunt.hcl
locals {
  parent = read_terragrunt_config(find_in_parent_folders("root.hcl"))
  aws_region = local.parent.locals.aws_region
}

Fix a misspelled attribute name

Match the reference exactly to the declared local name (case and spelling).

How to prevent it

  • Define shared locals once in a root config and read them explicitly.
  • Keep local names consistent across parent and child configs.
  • Run terragrunt hclvalidate locally to catch undefined references.

Frequently asked questions

What causes ""local ... is not defined""?
The locals { } block in this file does not define the name, and no included parent contributes it.
How do I fix "local ... is not defined"?
Declare the local or read it from the parent

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card