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

Merge branch 'master' into 'master'

Add terraform validate check

See merge request to-be-continuous/terraform!72
parents 72bdbc4c 24de67cf
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -509,6 +509,10 @@ This job uses the _check_ mode, and fails if any file appears not being properly
| `TF_FMT_ENABLED`     | Set to `true` to enable terraform fmt                                                      | _none_ (disabled)    |
| `TF_FMT_ARGS`        | terraform fmt [options](https://developer.hashicorp.com/terraform/cli/commands/fmt#usage)                   | `-diff -recursive`   |

### `tf validate` job

The terraform [`validate` command](https://developer.hashicorp.com/terraform/cli/commands/validate) is usually used to validate the configuration files in a directory. It is very useful to check a terraform module.

## Variants

The Terraform template can be used in conjunction with template variants to cover specific cases.
+7 −0
Original line number Diff line number Diff line
@@ -164,6 +164,13 @@
        }
      ]
    },
    {
      "id": "tfvalidate",
      "name": "tfvalidate",
      "description": "Check your Terraform code with [tfvalidate](https://developer.hashicorp.com/terraform/cli/commands/validate#usage)",
      "enable_with": "TF_VALIDATE_ENABLED",
      "variables": []
    },
    {
      "id": "review",
      "name": "Review",
+16 −0
Original line number Diff line number Diff line
@@ -803,6 +803,22 @@ tf-fmt:
      when: never
    - !reference [.test-policy, rules]

tf-validate:
  extends: .tf-base
  stage: test
  needs: []
  before_script:
    - *tf-scripts
    - cd "$TF_PROJECT_DIR"
    - terraform init -backend=false
  script:
    - terraform validate
  dependencies: []
  rules:
    - if: '$TF_VALIDATE_ENABLED != "true"'
      when: never
    - !reference [.test-policy, rules]

# =============================================================================
# === Review env jobs
# =============================================================================