Use Resource Targeting with CautionResource targeting (e.g., using
-target
during planning or applying) can lead to unintended consequences by modifying only a subset of your infrastructure, potentially leaving resources in an inconsistent state.For more details, refer to the OpenTofu documentation on resource targeting.Supported versions
Targeted deployments are not supported on self-hosted agents prior to version3.0.611
. However, the ENV0_TERRAFORM_TARGET
environment variable can still be used.
Using Resource Targeting
Below are all the different ways in which targets could be specified.Combining Target InputsMore than 1 option could be used at a time.env zero will take into account all the different definitions of targets, and combine them.
Using the UI
Whenever you deploy or re-deploy, you can open theTargeted Resources
section.

Adding a Custom TargetThe list of resources contains resources from the latest deployment.So when adding new resources, they wonโt be present in the list - but only after theyโre deployed.If you want to target new additions, you need to add them manually by typing their full address, and hitting
Enter
Using the ENV0_TERRAFORM_TARGET variable
Another option is to use theENV0_TERRAFORM_TARGET
control variable.
Simply set the environment variable, separated with commas for multiple values, and it will be directly converted to -target
flags.
Using the TF_CLI_ARGS_plan variable
TheTF_CLI_ARGS_plan
is nifty for forcing flags and arguments to commands.Providing a list of targets for
TF_CLI_ARGS_plan
would therefore take effect over deployments in env zero.
TF_CLI_ARGS_applyNote - the
TF_CLI_ARGS_apply
will NOT take effect since env zero runs your plan behind the scenes. Hence, it is recommended to either be used with the same value as TF_CLI_ARGS_plan
, or not be used at all.Viewing Targeted Resources
After executing a targeted deployment, you can go to the deployment page and click on theTargeted Resources
field.

