| `tftest-strategy` / `TF_TFTEST_STRATEGY` | terraform test strategy<br\>one of: `disabled`, `single` (will run tests only on the environment mapped to the pipeline branch) or `cascading` (will also run tests on downstream environments) | `disabled` |
In addition to a textual report in the console, this job produces the following reports, kept for one day and only available for download by users with the Developer role or higher:
| `$TF_PROJECT_DIR/reports/${ENV_TYPE}-tftest.xunit.xml` | [xUnit](https://en.wikipedia.org/wiki/XUnit) test report(s) | [GitLab integration](https://docs.gitlab.com/ci/yaml/artifacts_reports/#artifactsreportsjunit) |
#### Customizing Terraform Tests per Environment
By default, when `tftest-strategy` is set to `cascading`, Terraform tests will run for all enabled environments. However, you may want to disable tests for certain environments (e.g., production) to avoid resource costs or long execution times.
To disable tests for a specific environment while keeping other jobs (plan/apply) enabled:
This approach allows production deployments to continue working normally while preventing resource-intensive infrastructure tests from running in production.
#### Customizing Test Files per Environment
You can run different test files or use different test directories for each environment using the TF_<ENV>_TFTEST_OPTS variables.
This allows you to run lightweight tests in review environments and more comprehensive tests in staging, while potentially skipping expensive tests in production entirely.
### [DEPRECATED] `tf-tfsec` job
:warning: `tfsec` has been deprecated, it is recommended to use [trivy](#tf-trivy-job) instead.
"description":"terraform test strategy\n\none of: `disabled`, `single` (will run tests only on the environment mapped to the pipeline branch) or `cascading` (will also run tests on downstream environments)",
"type":"enum",
"values":["disabled","single","cascading"],
"default":"disabled"
},
{
"name":"TF_TFTEST_OPTS",
"description":"Extra options for the terraform native test feature",
description:terraform docs output directory (relative to `$TF_PROJECT_DIR`)
default:docs
tftest-strategy:
description:|
terraform test strategy
one of: `disabled`, `single` (will run tests only on the environment mapped to the pipeline branch) or `cascading` (will also run tests on downstream environments)
options:
-disabled
-single
-cascading
default:disabled
tftest-opts:
description:terraform test extra [options and args](https://developer.hashicorp.com/terraform/cli/commands/test)