gitlab-ci: Terraform has no command named "sh". Did you mean "show"

Viewed 1301

I'm trying to set up Terrafom validation on Gitlab CI.
However a build fails with an error: "Terraform has no command named "sh". Did you mean "show"?"

Why does it happen? How could it be fixed?

My .gitlab-ci.yml

image: hashicorp/terraform:light

before_script:
  - terraform init

validate:
  script:
    - terraform validate
1 Answers

You need to override the entrypoint in the terraform image so you have access to the shell.

image: 
  name: hashicorp/terraform:light
  entrypoint: [""]

before_script:
  - terraform init

validate:
  script:
    - terraform validate

You can also take a look at the official gitlab documentation how to integrate terraform with gitlab, as the have a template for that.

Related