Why is `-target` considered dangerous?
AdvancedConceptWorkflow and CLI
Answer
-target limits the plan to chosen resources and their dependencies, ignoring everything else. State and reality can drift from the code, and Terraform warns that it is "not for routine use". It is for recovery cases such as breaking a dependency cycle or applying a broken resource first. If you use it routinely, your root module is too big.
terraform apply -target='module.network.aws_subnet.private["a"]'
More on Workflow and CLI
What does `terraform init` do?BeginnerWhat does `terraform plan` do?BeginnerWhat does `terraform apply` do and what is `-auto-approve`?BeginnerWhat does `terraform destroy` do?BeginnerWhat do `terraform fmt` and `terraform validate` check?BeginnerWhy save a plan with `-out` and apply that file?Intermediate