Consider that under terraform folder, there are dev/ prod/ global/. So how many times do we need to run terraform init
?
Based on the transcript, you have the following folders under your terraform folder:
- dev/
- prod/
- global/
You also have a V2 folder that represents a single Git repository, which contains subfolders for environments (dev, prod, global) and modules.
To answer your question, you would need to run terraform init
in each environment folder (dev, prod, global) because each environment folder has its own Terraform state file.
However, in the V2 folder, you have a more advanced structure where each module is in its own Git repository. In this case, you would need to run terraform init
in each environment folder (dev, prod, global) as well as in each module repository.
So, in total, you would need to run terraform init
at least 5 times:
- 3 times in the environment folders (dev, prod, global)
- 2 times in the module repositories (VPC and subnet)
But, if you have more modules, the number of terraform init
commands would increase accordingly.
Common Terraform Execution Steps
terraform init
:terraform plan
:terraform apply
:terraform destroy