Additional Controls

🚧

Disclaimer

Additional Controls are features that aren’t available through the user interface, but can be used by setting the appropriate environment variables, at the Organization, Template, Project, or Environment level.

📘

OpenTofu Support

All controls that relate to Terraform should control OpenTofu the same way.

Terraform Targeted Apply

Using the ENV0_TERRAFORM_TARGET environment variable, you can specify specific resources that will be targeted for apply. The value of the variable will be passed to Terraform -target flag.
Read more here.

Specify Terraform/Terragrunt Versions

Using the ENV0_TF_VERSION environment variable, you can specify the Terraform version you would like your environment to use. You can read more here.

You can also use the ENV0_TERRAGRUNT_VERSION environment variable to specify the Terragrunt version for your applicable Terragrunt deployments.

Another way for determining the version for both Terraform and Terragrunt is a version file. When a file with a name .{type}-version (type being either "terraform" or "terragrunt") exists in the project's root directory the version is resolved based on the content of the file. The sole content of the file should be the version you wish to use.

The order of precedence whenever the version is specified using more than one option is as follows: env0 environment variable, version file, version selected when creating/updating the template.

📘

Specifying version in Terraform code

You can also set the version in your Terraform code and we will automatically install the correct version for using tfenv

Custom Terraform Variables File

Using the ENV0_TERRAFORM_CONFIG_FILE_PATH environment variable, you can select multiple Terraform variable files to pass on to Terraform. The list of filenames should be comma delimited.

Terraform Backend Config

Using the ENV0_TERRAFORM_BACKEND_CONFIG environment variable, you can pick a custom backend config to be used in terraform init. The value of the variable will be passed to the -backend-config flag.
If you would like to have multiple -backend-config declarations, then you can pass the multiple values in the ENV0_TERRAFORM_BACKEND_CONFIG environment variable as a comma-delimited string. For example, a value of /path/to/config/file,key=value will result in the flags -backend-config="/path/to/config/file" -backend-config="key=value".
Read more here.

Enable Cost Tagging Per Environment

Cost tagging works on the project level and once enabled, env0 will tag every environment under that project. It can happen that sometimes (mainly for debugging purposes) you'd wish to turn on cost tagging only for a specific environment and not for the whole project.
Using the ENV0_ENABLE_COST_TAG environment variable, you can enable it per your environment.

Adding Custom Resource Tagging

When cost tagging is enabled for an environment, using the ENV0_CUSTOM_TAGS environment variable will enable custom resource tags to be applied using terratag ( for terraform & terragrunt ) or natively for other IaCs.
The variable value should be supplied in the form of: {"aTagName": "aTagValue", ...}.
This would apply the tags to all taggable resources in the environment.
You can use another environment variables in the tags, for example {"created_by": "$ENV0_ENVIRONMENT_CREATOR_NAME"}. See this list for the environment variables that env0 exposes.

Skip Workspace Commands

For each environment, we are creating a new terraform workspace if it doesn't exist, or selecting it if it exists. In addition, we delete the workspace when destroying the environment.
If you wish not to execute those commands you can skip them by using the ENV0_SKIP_WORKSPACE environment variable and set its value to be true. Please remove the environment variable all together or set its value to be empty to run the workspace commands.

Skip Git Submodules

By default if you have git submodules configured in your repository env0 clone them with depth of 1.
If you do not wish to clone your git submodules you can by using the ENV0_SKIP_SUBMODULE_GIT_CLONE environment variable and set its value to be true.
If you remove the environment variable all together or set its value to be empty we will clone your git submodules.

Skip Get Working Directory

If you do not want to use the current working directory, set ENV0_IGNORE_STATE=true

Omit Plan Files In Terragrunt Run-All

If run-all apply is failing, you can try omitting plan files from plan and apply steps by setting ENV0_OMIT_TERRAGRUNT_RUN_ALL_PLAN_FILE=true. Read more here

✏️ Suggested Blog Content

Terraform Modules Guide

Terraform Plan Examples

Managing Terraform Variable Hierarchy

Manage Terraform Remote State with a Remote Backend