Skip to content

Add terraform fmt to Terraform.gitlab-ci.yml

Proposal

I currently use Terraform.gitlab-ci.yml in my pipeline.

Terraform has for some time the built-in command fmt.

Additionally, there's a -check option that wouldn't change the file but only return a non-zero exit code in case one or more files need changes.

Note that this command performs a different task than the already included validate.

Follow my custom pipeline as a practical example:

include:
  - template: Terraform.gitlab-ci.yml

lint:
  stage: validate
  script:
    - cd ${TF_ROOT}
    - gitlab-terraform fmt -check -recursive

At this point my proposal is obvious, I'd like to include the fmt in the GitLab template.

Edited by Marcel Amirault