No Module named "" is declared in the root module


I was trying to create output module and used in the Dev environment and getting the below error.

vpc_id = module.vpc.vpc_id
No module call named “vpc” is declared in the root module.

Can someone please guide me to get it fixed?

Thank you

Hi @aneee22,

This error message is saying that there is no module "vpc" block in the module where you wrote module.vpc. Some possible causes of that include:

  • The actual module call (module block) has a different name, perhaps due to a typing error.
  • The module "vpc" block is in a different module. In that case, you can’t refer to it from the root module without exporting it from the other module as an output value.

Unfortunately I can’t give any more suggestions without some more information, such as a fuller copy of what your current configuration looks like.

yes, I have the same problem but there are no satisfying responses in any forums. Terraform modules and variables are very problematic, not working as well as documented.

Hi @tirelibirefe,

This is an old topic but it seems like it wasn’t resolved because there wasn’t enough information to resolve it. I asked for more information and the original requester did not respond.

I’m happy to try to help with your question too, but again you have not shared enough information for me to guess what might be happening. If you’d like to talk about this some more, please start a new topic in this category and share the full error message you saw, exactly as Terraform printed it, along with the source code that the error relates to.

That will give the best chance that I or someone else in the forum will be able to explain what’s happening and suggest how to fix it.