Skip to content
Snippets Groups Projects
Unverified Commit 35db3ed9 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: add a terraform format checker task

parent 231c3674
No related branches found
No related tags found
No related merge requests found
Pipeline #13572415 passed
Loading
Loading
@@ -211,3 +211,26 @@ include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
file: tflint.yml
```
### [`terraform-format`](./terraform-format.yml)
Runs [`terraform fmt`](https://www.terraform.io/cli/commands/fmt) to ensure that all Terraform files are correctly formatted.
1. Ensure that the `GL_ASDF_TERRAFORM_VERSION` version for terraform is configured.
```yaml
stages:
- validate
# Not needed if .gitlab-ci-asdf-versions.yml is included...
variables:
GL_ASDF_TERRAFORM_VERSION: ...
include:
# Not required, but recommended
- local: .gitlab-ci-asdf-versions.yml
# Ensures that all terraform files are correctly formatted
- project: 'gitlab-com/gl-infra/common-ci-tasks'
file: terraform-format.yml
```
terraform_format:
stage: validate
needs: []
image:
name: hashicorp/terraform:${GL_ASDF_TERRAFORM_VERSION}
entrypoint: [""]
script:
- terraform fmt -recursive -diff -check .
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment