Looking for a way to exclude a resource unless explicitly targeted

Is there a way to mark a resource so that normal actions of plan & apply will ignore it unless it is explicitly targeted?

when = target

Would be ideal.

Hi @RoyceTheBiker,

Unfortunately, there is no such feature in Terraform today. Indeed, even the existing -target feature is there only for specialized, occasional use and is not considered part of the main Terraform workflow.

If you have parts of your infrastructure that you want to work with separately, the standard way to represent that is to write two separate Terraform configurations, and then run terraform apply in each of them separately so that each of them has an independent state.

1 Like