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.