Skip to content

*.tofu files are ignored, only *.tf files are recognized #4793

@lopter

Description

@lopter

Describe the bug

*.tofu files are not recognized by terragrunt as we can see in the source code, it's mostly globs on *.tf.

% git rev-parse HEAD
ffda97a1cf0161264a902c2a24016fc6d01618e8
% rg -g '*.go' '\*\.(tofu|tf)'
tf/getproviders/constraints.go
26:     tfFiles, err := filepath.Glob(filepath.Join(workingDir, "*.tf"))
33:     tofuFiles, err := filepath.Glob(filepath.Join(workingDir, "*.tofu"))

config/config_helpers.go
1100:// readTFVarsFile reads a *.tfvars or *.tfvars.json file and returns the contents as a JSON encoded string

cli/commands/run/run.go
77:const TerraformExtensionGlob = "*.tf"
626:    definesBackend, err := util.Grep(terraformBackendRegexp, opts.WorkingDir+"/**/*.tf")
640:    definesJSONBackend, err := util.Grep(terraformJSONBackendRegexp, opts.WorkingDir+"/**/*.tf.json")

cli/commands/aws-provider-patch/aws-provider-patch.go
82:// NOTE: this method only supports *.tf files right now. Terraform code defined in *.json files is not currently
120:                    matches, err := zglob.Glob(moduleAbsPath + "/**/*.tf")

cli/commands/run/download_source_test.go
534:                                    ExcludeFromCopy: &[]string{"*.tfstate", "excluded_dir/"},
537:                    expectedExcludeFiles: []string{"*.tfstate", "excluded_dir/"},

cli/commands/run/errors.go
42:     return "Did not find any Terraform files (*.tf) or OpenTofu files (*.tofu) in " + string(path)

cli/commands/run/download_source.go
196:    tfFiles, err := filepath.Glob(terraformSource.WorkingDir + "/*.tf")

internal/runner/common/unit_resolver.go
381:    matches, err := filepath.Glob(filepath.Join(filepath.Dir(terragruntConfigPath), "*.tf"))

internal/remotestate/remote_state.go
160:    file, err := os.CreateTemp("", "*.tfstate")
% 

Steps To Reproduce

Create a Tofu module with *.tofu files and no *.tf files. Drop-in a terragrunt.hcl, try to do some terragrunt run --log-level=debug … and you will see:

14:53:55.109 DEBUG  Unit . does not have an associated terraform configuration and will be skipped.

Expected behavior

.tofu files are first class citizens the way .tf files are.

Versions

% terragrunt --version
terragrunt version v0.86.0
% tofu --version
OpenTofu v1.10.5
on linux_amd64
% nixos-version 
25.11.20250821.323333f (Xantusia)
% 

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpreservedPreserved issues never go stale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions