Commit b4972aa4 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

doc(tfstate): detail required http backend config

parent 88160406
Loading
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -199,12 +199,27 @@ As a result if you enabled your `production` environment, every merge request wi

### Terraform Backend management

#### GitLab managed Terraform State (default)

By default, this template enables [GitLab managed Terraform State](https://docs.gitlab.com/ee/user/infrastructure/terraform_state.html).
As mentionned in GitLab's documentation, that requires that your Terraform scripts declare the
Terraform [HTTP backend](https://developer.hashicorp.com/terraform/language/settings/backends/http), the templates
does the rest to configure it automatically.

This default behavior can be disabled by setting `$TF_GITLAB_BACKEND_DISABLED` to `true`.
[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)
Terraform [HTTP backend](https://developer.hashicorp.com/terraform/language/settings/backends/http), 
and the template will do the necessary to configure it automatically.

All you have to do if you want it is to add the following in one of your `.tf` files:

```terraform
terraform {
  # using GitLab http backend
  backend "http" {
    # auto-configured by the template
  }
}
```

This default behavior can also be disabled by setting `$TF_GITLAB_BACKEND_DISABLED` to `true`.
In that case, you'll have to declare and configure your backend and tfstate by yourself (see [Implicit Backend configuration support](#implicit-backend-configuration-support) below).

#### _Error acquiring the state lock_ workaround