I have 3 .tf files in my terraform root directory:
- vpc.tf
- subnets.tf
- instances.tf
- Along with the .terraform directory after running terraform init
I would like to deploy only vpc.tf running something like:
terraform apply vpc.tf #here, vpc.tf is a terraform file
But it doesn't work (I get a Go error: "zip: not a valid zip file"). If I just run
terraform apply
it will try to apply all configurations in all 3 terraform files (vpc.tf, subnets.tf and instances.tf) which is not what I want. It seems that the way to have this to work is, have a completely different folder, and run something like
terraform apply vpc/ #here, vpc/ is a folder that containers vpc.tf file
which works. The problem with this approach, is that if I have 2 or more terraform files within the vpc/ folder, I come back to the first problem all over again. It seems the solution for this is to have a specific resource in a specific folder, but this doesn't seem clean, as I can foresee that if the infrastructure grows, I will end up with several folders containing a few terraform files. So the question is:
Is there a way to "terraform apply" a specific terraform file, and ignore all the rest within a folder? Am I missing something basic about terraform?