0

I have some Terraform configuration which has up until now run successfully without any issues locally and without me explicitly inserting any provider block.

I transferred this very same set of configuration to a GitLab pipeline with 4 pipeline stages of Validate, Plan, Apply and Destroy declared in my .gitlab-ci.yml file and suddenly the 'terraform plan' command fails at the Plan stage with the below "Invalid provider configuration" error.

enter image description here

This is all despite the fact that the 'terraform validate' command runs successfully at the initial pipeline stage - Validate.

Any idea why my configuration will suddenly be throwing this error in my GitLab pipeline when it's been perfectly fine when run locally?

hitman126
  • 699
  • 1
  • 12
  • 43
  • Did you install the plugins? What version of terraform are you using locally and what version of terraform are you using in GitLab CI? – sytech Mar 31 '22 at 23:30
  • Do you have `provider "vault"` and `provider "azuread"` blocks in your root module to specify the required settings for these two providers? – Martin Atkins Apr 01 '22 at 00:38
  • `terraform validate` doesn't configure providers, because it's intended for use in contexts where you might not have provider credentials available, such as CI runs in a VCS. `terraform plan` is a more thorough validation which considers external inputs such as available credentials, input variables, etc, and so it will often catch things that `terraform validate` cannot. – Martin Atkins Apr 01 '22 at 00:39
  • Appreciate the good feedback svtech and @Martin Atkins. In answer to your respective questions, no I don't install any plugins and on the subject of version of terraform used locally as against that in my GitLab CI, I doubt that could be the cause, as other terraform pipelines (aside this specific one) run successfully on our GitLab CI server. Martin Atkins makes a good point regarding the two provider blocks - my answer to that is no, I don't have them in my root module and didn't include them as I didn't require them locally. I will however insert them in the GitLab instance and retry. – hitman126 Apr 01 '22 at 06:31
  • Probably locally you already have som environments variables setted like `VAULT_ADDR` for the vault provider. My point is that the machine is not the same, so probably something is missing on GitLab runner that is automatically found in your local machine. – Danilo Cacace Apr 01 '22 at 13:20

0 Answers0