pre-commit-terraform icon indicating copy to clipboard operation
pre-commit-terraform copied to clipboard

tfupdate version constraints

Open chris3ware opened this issue 2 years ago β€’ 0 comments

What problem are you facing?

I am trying to integrate tfupdate into my pre-commit configuration. It works perfectly for exact versions i.e:

- --args=--version 0.7.1

tfupdate also supports terraform version constraints - but I am struggling to use this functionality with pre-commit so I wondered if it was supported or if I was doing something wrong?

My attempted configuration looks like this:

- id: tfupdate
  name: Terraform provider version SOPS
   args:
       - --args=provider sops
       - --args=--version ">= 0.7.1"

The error returned when running pre-commit run is this:

Terraform provider version SOPS..........................................Failed
- hook id: tfupdate
- exit code: 1

The command expects 2 arguments, but got 3

The associated tfupdate command (tfupdate provider --version ">= 0.7.1" --recursive sops .) run from the CLI works as expected.

How could pre-commit-terraform help solve your problem?

Should terraform pre-commit accept version constraint arguments for tfupdate? A good use case for this is required_providers in a module. For example for current AWS provider looks like this - but I don't think I can enforce this with pre-commit tfupdate currently.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 3.71.0, < 4.0.0"
    }
}

My tfupdate version is: 0.6.5 pre-commit terraform version is: 1.71.0

chris3ware avatar May 25 '22 10:05 chris3ware