0

I've the infrastructure of my app defined in terraform/terragrunt. To be able to deploy the full app in different environments I created a single module with the whole app. However I keep getting:

Error downloading modules: Error loading modules: module xxx: No Terraform configuration files found in directory: .terraform/modules/59ff835a2c7f654267e9f157739ec63a

Couldn't really figure out the problem

Federico
  • 1,636
  • 2
  • 22
  • 24

2 Answers2

3

Terraform will produce this message if the package/directory indicated as source does not include any .tf files.

One reason this might occur is if the source refers to a package (e.g. a repository, or an archive) that actually contains multiple modules in sub-directories, with nothing in the root directory. While the Standard Module Structure calls for there to be some sort of "default" combining module in the root, with other sub-modules then serving as separated components of that default, that is a convention rather than a requirement and if desired a package can contain only modules in sub-directories.

To refer to a module in a subdirectory, use the special double-slash // separator to split the package path from the subdirectory path.

For example, to access the modules/consul-cluster subdirectory of the hashicorp/consul/aws module in Terraform Registry, your full source address would be hashicorp/consul/aws//modules/consul-cluster. Similarly, for a subdirectory vpc of a git repository source git::https://example.com/network.git, you'd set source to git::https://example.com/network.git//vpc.

Whichever directory you specify must contain at least one .tf file for Terraform to consider it to be a valid Terraform module.

Martin Atkins
  • 62,420
  • 8
  • 120
  • 138
0

The problem was that I kept the multiple directory structure, eg: security/iam and the files inside such directories. Seems modules don't support this, just a flat directory structure. In the end I kept my single module app in a flat directory with a prefix in the files for "namespacing".

Btw, this is an intermediate refactor until I can create more modules for the app.

Federico
  • 1,636
  • 2
  • 22
  • 24