Interview Prep/Terraform/Modules, Variables, Sensitive Values and Workspaces

A data source inside a reusable module fails in some accounts with `no matching EC2 VPC found`.

IntermediateTroubleshootingModules, Variables, Sensitive Values and Workspaces
Answer

Likely causes → The module looks up a VPC by tag (Name = "main") that isn't consistent across accounts, or the provider region differs.

Diagnose → aws ec2 describe-vpcs --filters Name=tag:Name,Values=main --region ap-south-1

Fix → Pass vpc_id as an input instead of looking it up inside the module.

Prevent → Reusable modules should take IDs as inputs; root modules do the lookups.

All Terraform questions Roadmap: Terraform

More on Modules, Variables, Sensitive Values and Workspaces