This template enables [Terraform integration in Merge Requests](https://docs.gitlab.com/ee/user/infrastructure/mr_integration.html).
This template enables [Terraform integration in Merge Requests](https://docs.gitlab.com/ee/user/infrastructure/iac/mr_integration.html).
As a result if you enabled your `production` environment, every merge request will compute and display infrastructure changes compared to `master` branch.
@@ -201,7 +201,7 @@ As a result if you enabled your `production` environment, every merge request wi
#### GitLab managed Terraform State (default)
By default, this template enables [GitLab managed Terraform State](https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html).
By default, this template enables [GitLab managed Terraform State](https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html).
[As mentionned in GitLab's documentation](https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html#initialize-a-terraform-state-as-a-backend-by-using-gitlab-cicd),
that requires that your Terraform scripts declare the (unconfigured)
@@ -285,6 +285,25 @@ Be aware of the following:
* if the specified workspace doesn't exist, the template will create it,
And finally authentication credentials shall be defined as secret [environment variable credentials](https://developer.hashicorp.com/terraform/cli/config/config-file#environment-variable-credentials).
In the above example, that would mean defining a :lock: `TF_TOKEN_tf_registry_address` project variable containing the authentication token.
:warning: by default the template automatically sets the authentication token for the GitLab Modules Registry using the `$CI_JOB_TOKEN` value.
If you want to use another credential (personal access token or else), just define explicitly :lock: `TF_TOKEN_gitlab_com` (or the right one for your GitLab server)
as a project variable with the desired credential.
### Terraform lock file
As explained in [Terraform documentation](https://developer.hashicorp.com/terraform/language/files/dependency-lock#lock-file-location), _you should include the `.terraform.lock.hcl` file in your version control repository_.
@@ -314,7 +333,7 @@ The Terraform template uses some global configuration used throughout all jobs.
| `TF_IMAGE` | the Docker image used to run Terraform CLI commands <br/>:warning: **set the version required by your project** | `registry.hub.docker.com/hashicorp/terraform:latest` |
| `TF_GITLAB_BACKEND_DISABLED`| Set to `true` to disable [GitLab managed Terraform State](https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html) | _none_ (enabled) |
| `TF_GITLAB_BACKEND_DISABLED`| Set to `true` to disable [GitLab managed Terraform State](https://docs.gitlab.com/ee/user/infrastructure/iac/terraform_state.html) | _none_ (enabled) |
| `TF_SCRIPTS_DIR` | Terraform (hook) scripts base directory (relative to `$TF_PROJECT_DIR`) | `.` |
| `TF_OUTPUT_DIR` | Terraform output directory (relative to `$TF_PROJECT_DIR`). Everything generated in this directory will be kept as job artifacts. | `tf-output` |