When is `-target` acceptable, and when is it a red flag?
IntermediateScenarioWorkflow and Providers
Answer
Situation read → An engineer wants to apply one resource to "save time".
What I'd do →
- Allow it for recovery, such as fixing a broken dependency or getting past an error to unblock the graph.
- Follow every targeted apply with a full
terraform planthat must converge to no changes. - Refuse it as a routine workflow or in pipelines.
terraform apply -target=aws_iam_role.deploy
terraform plan # must be clean afterwards
Why → Terraform itself warns that targeting is for exceptional situations; it skips parts of the graph, so outputs and dependent resources can go stale.
Interview tip → Offer the real fix for slow plans: smaller states.
More on Workflow and Providers
A new teammate is about to run Terraform for the first time against a shared dev account. Which commands do you walk them through, and in what order?BeginnerYour manager asks why we bother with `terraform plan` when `apply` shows the same diff before asking for confirmation. What do you say?BeginnerTwo engineers get different provider versions and see different plans for the same code. How do you stop this?BeginnerSomeone committed the `.terraform/` directory to the repo. What should be in version control and what should not?BeginnerThe same configuration must create a VPC in `us-east-1` and a DR copy of a bucket in `eu-west-1`. How do you do it with one root module?IntermediateYou must deploy the same stack into 12 AWS accounts. How do you handle credentials and provider configuration?Intermediate