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

feat: Include .tfbackend files in hooks

Open thiagowfx opened this issue 8 months ago β€’ 15 comments

Blocked as there Upstream FR / bug: https://github.com/hashicorp/terraform/issues/36564


Put an x into the box if that apply:

  • [ ] This PR introduces breaking change.
  • [ ] This PR fixes a bug.
  • [ ] This PR adds new functionality.
  • [x] This PR enhances existing functionality.

Description of your changes

As per the official docs https://developer.hashicorp.com/terraform/language/backend#file:

A backend configuration file has the contents of the backend block as top-level attributes, without the need to wrap it in another terraform or backend block:

address = "demo.consul.io"
path    = "example_app/terraform_state"
scheme  = "https"

*.backendname.tfbackend (e.g. config.consul.tfbackend) is the recommended naming pattern. Terraform will not prevent you from using other names but following this convention will help your editor understand the content and likely provide better editing experience as a result.

How can we test changes

Add foo.tfbackend (a simple HCL file, without blocks, similar to .tfvars), run e.g. pre-commit run --all-files terraform_fmt.

thiagowfx avatar Feb 20 '25 13:02 thiagowfx