Targeted Deployments
Support
Targeted Deployments are not supported for self hosted agents prior to version
3.0.611
.However, the
ENV0_TERRAFORM_TARGET
variable will work.
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.
How To Target Resources
Below are all the different ways in which targets could be specified.
Combining Target Inputs
More than 1 option could be used at a time.
env0 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.
Then choose modules and resources using the autocomplete below.
Adding a Custom Target
The 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 env0.
TF_CLI_ARGS_plan="-target=resource1 -target=resource2"
TF_CLI_ARGS_apply
Note - the
TF_CLI_ARGS_apply
will NOT take effect since env0 runs your plan behind the scenes. Hence, it is recommended to either be used with the same value asTF_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.
And the full list of targeted resources and modules will pop up
Updated 12 months ago