This project implements a GitLab CI/CD template to manage your infrastructure with [Terraform](https://www.terraform.io).
This project implements a GitLab CI/CD template to manage your infrastructure with [Terraform](https://www.terraform.io) or [OpenTofu](https://opentofu.org/).
## Usage
@@ -48,6 +48,15 @@ variables:
This chapter introduces key notions and principle to understand how this template works.
### Terraform or OpenTofu support
Depending on which binary is available in the image (`image`/`TF_IMAGE`), this template allows usage of both Terraform or OpenTofu.
Any OpenTofu image from [GitHub Registry](https://github.com/opentofu/opentofu/pkgs/container/opentofu/versions) is supported by the template.
You may also build and use your [own image](https://opentofu.org/docs/intro/install/docker/).
If you need to migrate from Terraform to OpenTofu, please follow the [OpenTofu Migration Guide](https://opentofu.org/docs/intro/migration/migration-guide/).
### Managed deployment environments
This template implements continuous deployment on your infrastructure using Terraform.
@@ -499,12 +508,14 @@ In addition to a textual report in the console, this job produces the following
| `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:
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 when you are using terraform engine:
| `$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) |
OpenTofu test doesn't provide yet JUnit report, for more information see this [OpenTofu issue](https://github.com/opentofu/opentofu/issues/2501).
#### 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.