Structuring Terraform

Hello everyone,

This may be an extremely basic question but I’m currently unable to find a clear answer - how should i go about structuring my Terraform code? In my example i’m creating a VPC, EC2 instance, SSH Key, ELB, and SGs.

Initially I created these within a single root directory but I can see how this will get messy quickly especially as more services are added. I’ve started spliiting it off with the following:

├── environments
│ ├── dev
│ ├── prod
│ └── uat
├── main.tf
├── modules
│ ├── compute
│ │ └── main.tf
│ ├── keys
│ │ ├── main.tf
│ │ ├── remoteState.tf.off
│ │ ├── terraform.tfstate
│ │ └── variables.tf
│ └── networking
│ └── vpc
│ ├── main.tf
│ ├── terraform.tfstate
│ └── terraform.tfstate.backup
├── outputs.tf
└── remoteState.tf

My issue is though that there’s scenarios where I would like to run every single terraform to create an entire stack - in my situation it’s possible I will have up to 100+ VPCs all with identical infrastructure (one per customer).

At the moment I have to run each module individually. It’s certainly possible I’m just not grasping what Terraform is about.

Is there a way to run a global apply to create the entire stack and then in the future update individual components?

Sorry if this is confusing and I thank you for any help you may be able to give me.