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).
## Usage
@@ -132,7 +132,7 @@ Part of this complexity can be handled by using [Terraform variables](https://de
*`environment_type`: the current deployment environment type (`review`, `integration`, `staging` or `production`)
*`environment_name` (equals `$CI_ENVIRONMENT_NAME`): the full environment name (ex: `review/fix-prometheus-configuration`, `integration`, `staging` or `production`)
*`environment_slug` (equals `$CI_ENVIRONMENT_SLUG`): the [sluggified](https://en.wikipedia.org/wiki/Clean_URL#Slug) environment name (ex: `review-fix-promet-r13zmu`, `integration`, `staging` or `production`)
2. use [`tfvars` files](https://www.terraform.io/language/values/variables#variable-definitions-tfvars-files) for non-secret configuration:
2. use [`tfvars` files](https://developer.hashicorp.com/terraform/language/values/variables#variable-definitions-tfvars-files) for non-secret configuration:
* default `terraform.tfvars[.json]` and `*.auto.tfvars[.json]` files are obviously supported by Terraform,
* the template also auto-detects any file named `$environment_type.env.tfvars[.json]` (ex: `staging.env.tfvars` for staging environment) and uses it with all related `terraform` commands.
3. any [predefined GitLab CI variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html) may be freedly used in your hook scripts or extra options variables (ex: `TF_EXTRA_OPTS: "-var project_name=$CI_PROJECT_NAME"`)
@@ -260,7 +260,7 @@ terraform init \
#### Implicit Backend configuration support
If you disabled the GitLab-managed Terraform state (by setting `$TF_GITLAB_BACKEND_DISABLED` to `true`),
the template supports an implicit [backend configuration](https://www.terraform.io/language/settings/backends/configuration#file) mechanism:
the template supports an implicit [backend configuration](https://developer.hashicorp.com/terraform/language/settings/backends/configuration#file) mechanism:
1. Looks for a `$environment_type.tfbackend` file (ex: `staging.tfbackend` for staging environment),
2. Fallbacks to `default.tfbackend` file.
@@ -269,7 +269,7 @@ If one of those files are found, it is automatically used by the template in the
#### Workspace management
You may want to make use of [Terraform Workspace](https://www.terraform.io/language/state/workspaces)
You may want to make use of [Terraform Workspace](https://developer.hashicorp.com/terraform/language/state/workspaces)
to ease segregating you multiple environments (tfstate management) by setting variables: