Using Terraform 0.12.6
I have a directory with multiple *.tf files, e.g., product1.tf, product2.tf etc. How can I execute terraform plan and subsequently terraform apply for a certain *.tf file? I was hoping it would be the -target option but I read the docs and didn't see this mentioned.
You can't. Terraform concatenates all the
.tffiles in a directory and works on them all at once.You can use
-targetto target specific resources but it has no idea what file they're all in.-targetin general should be used sparingly as an escape hatch, if you need to run separate bits of Terraform at a time then split your Terraform code up into separate directories and state files.This is also discussed in the docs: