Skip to main content
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.
Targeting resources and modules allows us to pinpoint exactly what needs to be changed instead of deploying a whole environment. Such selective deployments minimize risks associated with broader changes, ensuring that updates are precise and efficient. This precision is useful for testing, enabling quicker iterations and focused debugging. With Targeted Deployments, teams can confidently experiment with changes, minimizing risks and streamlining development workflows.

Supported versions

Targeted deployments are not supported on self-hosted agents prior to version 3.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 the Targeted Resources section.
Interface screenshot showing configuration options
Then choose modules and resources using the autocomplete below.
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 the ENV0_TERRAFORM_TARGET control variable. Simply set the environment variable, separated with commas for multiple values, and it will be directly converted to -target flags.
ENV0_TERRAFORM_TARGET="resource1,resource2"
Since this is an environment variable, targeting persists as long as the variable is defined.

Using the TF_CLI_ARGS_plan variable

The TF_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_plan="-target=resource1 -target=resource2"
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.
Since this is an environment variable, targeting persists as long as the variable is defined.

Viewing Targeted Resources

After executing a targeted deployment, you can go to the deployment page and click on the Targeted Resources field.
Interface screenshot showing configuration options
And the full list of targeted resources and modules will pop up
Interface screenshot showing configuration options
โŒ˜I