When looking at the registry for pre-built modules like this one:


How do you see the contents of the module? Looks like they are calling a module called vpc but I cannot find this module here:

So are they just calling a non existing vpc module for example showing reasons?

Hi @stevenjw0228001,

The GitHub repository you linked to here is the content of the terraform-aws-modules/vpc/aws module: the .tf files in the root of the repository are the implementation of the module.

Does that answer your question? I’m not fully sure I’m understanding your question correctly.

1 Like

I guess I would have thought the root .tf files would call the module called “complete-vpc” from here:

terraform-aws-vpc/examples at master · terraform-aws-modules/terraform-aws-vpc · GitHub)/complete-vpc/ main.tf

In that main.tf its calling Module “vpc” and the source = “…/…/”

But thats just saying two folders up in the chain of folders. Its not calling a file so how does it know?

Terraform doesn’t care about files only directories. You always tell Terraform a directory to look at, either in a module or when running the Terraform command itself - it them processes every single .tf file in that directory (filenames have no meaning).

1 Like

Hi @stevenjw0228001,

That example is a bit confusing because it’s written in a way that can only work when you use it from exactly that directory inside the module’s own repository. It works there because ../../ relative to examples/complete-vpc/ happens to be the root of the repository, where the module is.

If you wanted to copy that example and use it in your own configuration then you would need to change the source argument to be the address (and, optionally, version constraint) from the registry:

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "2.78.0"

  name = "complete-example"

  # ...etc...
1 Like

Ok this all makes sense now. Thanks for the clarity.